This post originated from an RSS feed registered with Java Buzz
by Chris Winters.
Original Post: Spring: Telling the framework where to load beans
Feed Title: cwinters.com
Feed URL: http://www.cwinters.com/search/registrar.php?domain=jroller.com®istrar=sedopark
Feed Description: Chris Winters on Java, programming and technology, usually in that order.
Earlier I discussed how to refer to multiple bean definition files in the DispatcherServlet declaration in your web.xml. But you can also refer to beans not in your WAR file using the classpath: prefix:
I don't think this is in the docs, or if it is I missed it. (RC2 is to be released today according to Juergen.) I found it out by opening up the org.springframework.web.context.support.XmlWebApplicationContext class and browsing to the loadBeanDefinitions() method. There you see a call:
Ctrl-B that 'getResource()' call and you'll jump to org.springframework.context.support.AbstractApplicationContext where you can easily (it's eight lines of code) dope out how they identify items on the classpath. This process took far longer to type out here than to actually do thanks to IDEA.
What prompted this? I split out the DAO/domain objects into their own entity -- IDEA: "module"; Maven: "project" -- and I didn't want to have to copy the generated spring-dao-objects.xml file over to the webapp. Once again, Spring lets you do the right thing...