Editing runtime classpath in IntelliJ to include src / main / config

I am writing a Java application in IntelliJ 12 using Maven and Spring. I have the following folders:

src / main / java : for Java code

src / main / resources : for resources to be packaged in the final JAR

src / main / config : for external resources, i.e. spring configuration file.

I tried to create the original src / main / config folder, however when starting my application it failed with a FileNotFoundException on the following line:

new ClassPathXmlApplicationContext("spring-config.xml");

      

spring-config.xml

is inside src / main / config .

Also, I noticed that this file is not copied to the target directory that intelliJ produces when "Make" creates the project.

I am currently resorting to using FileBasedApplicationContext for testing, however it would be nice to be able to run the application from IntelliJ without having to edit the code.

thank

+3


source to share


1 answer


See my comment here . Resource directories / templates must be explicitly defined in your file pom.xml

like this:



<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
        <resource>
            <directory>src/main/config</directory>
        </resource>
    </resources>
</build>

      

+5


source







All Articles