Spring MVC 中的@ImportResource 路径
@ImportResource path in Spring MVC
我在 /WEB-INF 路径中有一个 Spring-Datasource.xml 文件。我想在 AppConfig.java 中导入它,它是一个配置文件。 NetBeans IDE 中@ImportResource 的正确路径是什么?我在 Spring MVC 中编码。我知道我应该使用:
@ImportResource(classpath:Spring-Datasource.xml)
但是没用。
项目层次结构:
-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 目录路径在类路径中不可用 Spring project.Move 文件到 src/main/resources 并按如下方式导入:
@ImportResource(classpath:Spring-Datasource.xml)
类路径是 src/main/resources
如果你的文件在那里,那么就对了 @ImportResource("classpath:SpringDatasource.xml")
我在 /WEB-INF 路径中有一个 Spring-Datasource.xml 文件。我想在 AppConfig.java 中导入它,它是一个配置文件。 NetBeans IDE 中@ImportResource 的正确路径是什么?我在 Spring MVC 中编码。我知道我应该使用:
@ImportResource(classpath:Spring-Datasource.xml)
但是没用。 项目层次结构:
-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 目录路径在类路径中不可用 Spring project.Move 文件到 src/main/resources 并按如下方式导入:
@ImportResource(classpath:Spring-Datasource.xml)
类路径是 src/main/resources
如果你的文件在那里,那么就对了 @ImportResource("classpath:SpringDatasource.xml")