Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java IntelliJ IDEA无法解析spring导入的文件_Java_Spring_Maven_Intellij Idea - Fatal编程技术网

Java IntelliJ IDEA无法解析spring导入的文件

Java IntelliJ IDEA无法解析spring导入的文件,java,spring,maven,intellij-idea,Java,Spring,Maven,Intellij Idea,我有一个多模块maven项目,包含父pom文件和两个模块(名为“app”和“modules”)。在“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"

我有一个多模块maven项目,包含父pom文件和两个模块(名为“app”和“modules”)。在“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上下文中对象的注入。若我将路径更改为文件:app/src/main/webapp/WEB-INF/spring config/security.xml,那个么一切都正常,但它会使maven测试崩溃


请告诉我如何配置IntelliJ IDEAs spring文件分辨率。

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


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

,因为它们不应该。。。在运行时,路径
src/main/webapp
不存在,这仅在构建时可用。只需使用
/WEB-INF/spring config
(无
文件:
前缀)即可。如果您希望这些文件可用于测试,我建议将这些文件从
WEB-INF
目录移到类路径上的某个位置,例如
src/main/resources/META-INF
。然后您可以执行
classpath:/META-INF/spring config/security.xml
etc.@M.Deinum谢谢!我已将spring配置文件夹移动到资源文件夹,并使用classpath:/spring config/security.xml refs。我所有的方案都有效!你能根据这个评论写一个答案吗?