sab
sab

Reputation: 9977

Who creates beans in a spring web application?

I know that in a standalone application I create one of the application context instances which in turn creates the beans from conf files. But I can not see any such code in dispatched servlet. How then are the beans created in a web application?

Upvotes: 1

Views: 157

Answers (1)

Bozho
Bozho

Reputation: 597096

The ContextLoaderListener creates an ApplicationContext (by delegating to ContextLoader) and stores it in the servlet context.

So you have to map the ContextLoaderListener is a <listener> in web.xml

Then, of course, that ApplicationContext (WebApplicationContext in this case) creates the beans.

Upvotes: 6

Related Questions