I am developing an example Spring MVC application which is a variation of what is described in the Spring MVC step-by-step tutorial. I have a Spring/Hibernate DAO class which is working well and I want to use this as a property of my Controller class for use within its handleRequest() method. In this Controller class I have a DAO private member, and a setter method for Spring to be able to set this property. I have the Spring wiring configuration split into two files, myapp-data.xml and myapp-servlet.xml.
The trouble is that when I run the application Spring croaks upon initializing the Controller bean because it can't find the definition for the DAO bean. It somehow knows how to find myapp-servlet.xml for the configuration of the Controller and ViewResolver beans, but it doesn't know to look for myapp-data.xml for the configuration of the DAO and HibernateTemplate beans.
Am I correct in assuming that I should have all Spring configuration files (in this case myapp-data.xml and myapp-servlet.xml) in the WEB-INF directory? If not then what is the most common or best place for these Spring config files? Perhaps the non-MVC config files should go elsewhere?
How does Spring magically know to look for myapp-servlet.xml for the configuration of the MVC components? I never specify this anywhere, so is this is a default convention?
For now I can get around the trouble by putting all of the Spring bean configuration into the myapp-servlet.xml, but I'd like to be able to split these apart as recommended in "Spring in Action". Can anyone sugget how I should go about doing this?
Thanks in advance for any suggestions.
--James


Reply With Quote