IntelliJ IDEA cannot resolve imported spring files

I have a multi-module maven project with a parent pom file and two modules (named "app" and "modules"). In the test resources "app" I have a spring configuration with the following content:

<?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 and 14 cannot find files that are imported as resources in my case (security.xml, mvc-servlet.xml and common.xml) and therefore IDEA cannot allow nesting objects from spring context. If I change the file path: app / src / main / webapp / WEB-INF / spring-config / security.xml then everything works fine, but it disables maven tests.

Please show me how to configure IntelliJ IDEAs spring file permissions.

+3


source to share


1 answer


The path src/main/webapp

does not exist at run time, it is only available at build time. Just use /WEB-INF/spring-config

(no file:

prefix).



If you want them to be available for testing, I suggest moving these files from the WEB-INF directory somewhere along the class path, i.e. src/main/resources/META-INF

, eg. Then you can doclasspath:/META-INF/spring-config/security.xml

+5


source







All Articles