Alex
Alex

Reputation: 4073

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

is this a more recommended way?

Upvotes: 1

Views: 653

Answers (1)

skaffman
skaffman

Reputation: 403441

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.

Upvotes: 1

Related Questions