instancenow
instancenow

Reputation: 43

Why spring only picks from src/main/resources folder to add to classpath?

Why spring only picks from src/main/resources folder to add to classpath ?

Upvotes: 1

Views: 1984

Answers (2)

shreyansh pandey
shreyansh pandey

Reputation: 363

Maven uses default classpath for the resource folder which is "src/main/resources" if you want to include your own custom folder to class path, you have to update pom.xml file to indicate maven to include your new folder into classpath. use following code template to update pom.xml

<build>
        ...
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            .....
            <resource>
                <directory>path to your folder to put in classpath</directory>
            </resource>
       </resources>
</build>

if your pom.xml file doesn't have build or resource tag already then just add only add following piece of code to pom.xml

<build>
       </resources>
            <resource>
                <directory>path to your folder to put in classpath</directory>
            </resource>
       </resources>
</build>

and check your Effective POM to verify that your custom folder and resource folder both are present there or not.

Upvotes: 0

Aeseir
Aeseir

Reputation: 8434

That is the default folder for spring spring maven project config. If you want to change it you can see the example here:

http://www.mkyong.com/maven/how-to-change-maven-resources-folder-location/

Otherwise for Annotated version you can view the Web Tutorial on the Spring.IO website:

http://spring.io/guides/tutorials/web/

Upvotes: 1

Related Questions