tags:

views:

30

answers:

1

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 getBean() calls, this bootstrap class must be executed at the startup of your webapplication

is this a more recommended way?

+1  A: 

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.

skaffman
would you please give me an answer to my edited question?
Alex