Is it recommended to physically have a file applicationcontext.xml or can I have all bean definitions in my app-servlet.xml file?
In other words, does Spring look in applicationcontext.xml for anything special?
Is it recommended to physically have a file applicationcontext.xml or can I have all bean definitions in my app-servlet.xml file?
In other words, does Spring look in applicationcontext.xml for anything special?
You need to physically have some context to boot from, but I guess you could have all your bean definitions in the app-servlet.xml file.
It would be a better architecture though, to keep them separate. For bigger applications, or even just for integration testing, it even makes sense to split applicationcontext.xml into several files.
If you want to use Hibernate OSIV then you will need to register a ContextListener which needs an appContext file.
I do have this in my web.xml, it's just that I'm not using a separate file (i.e. applicationContext.xml) -- is it enough (despite a bad design to have it all in one file)?
Code:<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/sas-servlet.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
If you are explicitly declaring the context, then no, you don't![]()
Thanks; I've been trying to minimize the number of XML files whenever it makes sense. Between Tiles, Hibernate, Spring, etc., the number of files can grow pretty quickly :-)
That's a good idea, but I wouldn't sacrifice modularity/readability. You can always separate the files into different directories.I've been trying to minimize the number of XML files whenever it makes sense. Between Tiles, Hibernate, Spring
Gotta agree with katentim, that good old OO rule "each thing does one thing, and one thing well" applies to XML files as well![]()