Spring Containers: Beans are constructed even if you never try to get it by default.

This is a concept might be overlooked by the beginners in Spring framework. When a Bean configuration is loaded in a IoC container, all the beans are constructed by default if you don’t specifically mentioned lazy loading on a bean. So,

ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
//

This single line loads all your bean objects! Remember that. One exception might be prototype. I didn’t test that yet, but the container should be loading one object at first.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s