Java @Spring MVC中的导入源路径
我在/WEB-INF路径中有一个Spring-Datasource.xml文件。我想在AppConfig.java中将其导入为配置文件。NetBeans IDE中@ImportResource的正确路径是什么?我在SpringMVC中编写代码。我知道我应该使用:Java @Spring MVC中的导入源路径,java,spring,spring-mvc,web-config,Java,Spring,Spring Mvc,Web Config,我在/WEB-INF路径中有一个Spring-Datasource.xml文件。我想在AppConfig.java中将其导入为配置文件。NetBeans IDE中@ImportResource的正确路径是什么?我在SpringMVC中编写代码。我知道我应该使用: @ImportResource(classpath:Spring-Datasource.xml) 但它不起作用。 Hirearchy项目: -FinalWebStore -Web Pages -WEB-INF
@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
...
在Spring项目的类路径中,WEB-INF目录路径不可用。请将文件移动到src/main/resources,并按如下方式导入:
@ImportResource(classpath:Spring-Datasource.xml)
Classpath它是
src/main/resources
,如果你的文件在那里,那么它就是正确的@ImportResource(“Classpath:SpringDatasource.xml”)
什么是确切的类路径?