Filip Górny
Filip Górny

Reputation: 1769

Spring Maven - context configuration in resources folder

As I found in other question at stackoverflow, it is better to keep the configuration of spring in src/main/resources folder. However when I use mvn jetty:run it tries to load context configuration from WEB-INF whatever I'm typing into web.xml. I get the following error:

javax.servlet.ServletException: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/easyscrum-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/easyscrum-servlet.xml]

What should I do to force servlet to load config from classpath instead of web-inf?

Upvotes: 1

Views: 1833

Answers (1)

Bhushan Bhangale
Bhushan Bhangale

Reputation: 10987

To load spring config context files from classpath you have to prefix the path with classpath:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:context.xml
    </param-value>
</context-param>

Upvotes: 3

Related Questions