I am trying to learn about the Spring framework for Java and I am not sure where about's I am supposed to put the applicationContext.xml file for configuring the spring beans. My directory structure is as follows:
Do I put in .settings? Or should it be put at the top level within springapp?
Thanks for the help.
In essence the Spring configuration files (that can have any name by the way, not just the generic applicationContext. xml ) are treated as classpath resources and filed under src/main/resources .
The basis for the context package is the ApplicationContext interface, located in the org. springframework. context package. Deriving from the BeanFactory interface, it provides all the functionality of BeanFactory .
Applicationcontext. xml - It is standard spring context file which contains all beans and the configuration that are common among all the servlets. It is optional file in case of web app. Spring uses ContextLoaderListener to load this file in case of web application.
Put into directory WebContent/WEB-INF
.
Resources placed into WEB-INF
folder are not accessible from web, they are application internal resources. This is good, because your applicationContext.xml
shouldn't be accessible from web.
Other good options are WebContent/WEB-INF/classes
or just src
(both are equal).
Files and folders with .
contains Eclipse configuration files, they are internal for Eclipse - do not use them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With