Container managed beans

Instead of a class creating its own dependencies, in the earlier example, we looked at how the Spring IoC container can take over the responsibility of managing beans and their dependencies. The beans that are managed by the container are called Container Managed Beans.

Delegating the creation and management of beans to the container has many advantages. Some of them are listed as follows:

  • Since classes are not responsible for creating dependencies, they are loosely coupled and testable. This leads to good design and fewer defects.
  • Since the container manages the beans, a few hooks around the beans can be introduced ...

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.