Tomcat Spring WebApplicationContext
In the Spring framework reference I found this:
The ApplicationContext interface has a few other methods for retrieving beans, but ideally your application code should never use them. Indeed, your application code should have no calls to the getBean method at all, and thus no dependency on Spring APIs at all.
but I have no idea to realize this.
After a lot of search I found this
avoid to use getBean in your application code, try to write a single class with one or more getB开发者_JAVA技巧ean() calls, this bootstrap class must be executed at the startup of your webapplication
is this a more recommended way?
Spring encourages you to use Inversion of Control, where the framework (e.g. Spring) injects dependencies into your objects, rather than your objects fetching things from the framework.
精彩评论