IntelliJ IDEA无法解析Spring导入的文件

维塔利·伊万诺夫(Vitaly Ivanov)

我有一个带有父pom文件和两个模块(分别名为“ app”和“ modules”)的多模块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>

在我的案例中,IntelliJ IDEA 13和14无法找到作为资源导入的文件(security.xml,mvc-servlet.xml和common.xml),因此IDEA无法解决从spring上下文注入对象的问题。如果我将路径更改为file:app / src / main / webapp / WEB-INF / spring-config / security.xml,则一切正常,但崩溃了maven测试。

请告诉我如何配置IntelliJ IDEA弹簧文件分辨率。

然后马库斯

在运行时,该路径src/main/webapp不存在,该路径仅在构建时可用。只需使用/WEB-INF/spring-config(无file:前缀)即可。

如果您希望它们可用于测试,我建议将这些文件从WEB-INF目录移到类路径的某个位置src/main/resources/META-INF,例如。那你可以做classpath:/META-INF/spring-config/security.xml

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章