@ImportResource在Spring MVC中的路径

问题描述:

我在/ WEB-INF路径中有一个Spring-Datasource.xml文件。我想在AppConfig.java中导入它,它是一个配置文件。 NetBeans IDE中@ImportResource的正确路径是什么?我在Spring MVC编码。我知道我应该使用:@ImportResource在Spring MVC中的路径

@ImportResource(classpath:Spring-Datasource.xml) 

但它不起作用。 项目Hirearchy:

-FinalWebStore 
    -Web Pages 
    -WEB-INF 
      +views 
      web.xml 
      mvc-dispatcher-servlet.xml 
      Spring-Datasource.xml 
    -Source Packages 
     +com.karans.finalwebstore.controllers 
     +com.karans.finalwebstore.daoimps 
     +com.karans.finalwebstore.daos 
     +com.karans.finalwebstore.models 
    +Dependecies 
... 

WEB-INF目录路径是不可用的春天project.Move类路径的文件为src /主/资源和如下导入:

@ImportResource(classpath:Spring-Datasource.xml) 
+0

究竟什么是类路径? – ma98

它的Classpath是src/main/resources,如果你的文件存在,那么将是正确的@ImportResource("classpath:SpringDatasource.xml")