Creating a Spring IoC container

There are two ways to create a Spring IoC container:

  • Bean factory
  • Application context
Bean factory is the basis for all Spring IoC functionality--bean life cycle and wiring. Application context is basically a superset of Bean factory with the additional functionality typically needed in an enterprise context. Spring recommends that you use the application context in all scenarios, except when the additional few KBs of memory that the application context consumes are critical.

Let's use an application context to create a Spring IoC container. We can have either a Java configuration or an XML configuration for an application context. Let's start with using a Java application configuration.

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.