I am reading a book on Spring and Spring MVC, and am trying out the sample application. The problem is that it’s a pre-release version of the book, and the full code isn’t available to download yet.
I want the beans from my service layer to be accessible via the web app. Do I have to declare them in two xml files? (One for the service layer, and one for the web app?) This code is given in the book to add to the web.xml file, but I am unsure what this solves:
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spitter-security.xml
classpath:service-context.xml
classpath:persistence-context.xml
classpath:dataSource-context.xml
</param-value>
</context-param>
But it does not say where the service-context.xml etc files are located, or what the folder structure is. How do they get on the classpath to be accessed by “classpath:”?
Can I have this xml file in one location to be accessed both by the main application and by the web application? Or do I need to declare my beans twice for when it gets deployed to Tomcat?
Any help would be appreciated as I am really confused about this. Thanks
the xml files specified above are located on the root of the classpath. i.e.
WEB-INF/classes. See here for more details