Vit*_*nov 4 java spring intellij-idea maven
我有一个带有父pom文件和两个模块(名为"app"和"modules")的multimodule maven项目.在"app"的测试资源中,我有一个spring配置,其中包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<import resource="file:src/main/webapp/WEB-INF/spring-config/security.xml"/>
<import resource="file:src/main/webapp/WEB-INF/spring-config/mvc-servlet.xml"/>
<import resource="file:src/main/webapp/WEB-INF/spring-config/common.xml"/>
<import resource="db-test.xml"/>
<import resource="utilsContext.xml"/>
</beans>
Run Code Online (Sandbox Code Playgroud)
IntelliJ IDEA 13和14找不到在我的情况下作为资源导入的文件(security.xml,mvc-servlet.xml和common.xml),因此IDEA无法解析弹簧上下文中对象的注入.如果我将路径更改为文件:app/src/main/webapp/WEB-INF/spring-config/security.xml,那么一切正常,但它会崩溃maven测试.
请告诉我如何配置IntelliJ IDEAs弹簧文件的分辨率.
在运行时,路径src/main/webapp不存在,这仅在构建时可用.只需使用/WEB-INF/spring-config(无file:前缀).
如果您希望它们可用于测试,我建议将这些文件从WEB-INF目录移到类路径上的某个位置src/main/resources/META-INF,例如.然后你可以做到classpath:/META-INF/spring-config/security.xml
| 归档时间: |
|
| 查看次数: |
5586 次 |
| 最近记录: |