Spring internals #1: ApplicationContext simple overview

Aleksei Novikov
4 min readFeb 25, 2023

You can be a good racer just by driving a car but you will never become the best one without knowing its internals.

Spring Framework is the most popular solution in Java world development. It provides dozens of functionalities, has a huge community, and is a feature-rich — production-ready tool.

With this article, I’m starting a series about Spring internals to tell you how the framework works under the hood. So, the first talk is going to be about the most important features of the framework — DI container and ApplicationContext. We will take a fast and simple overview of the core functionality and lifecycle.

First of all, let’s talk a bit about a lifecycle of a standard Spring application. If we create a simple application using Spring Framework, we should create an application context first. To do so, we have a few implementations standard implementations:

  • ClassPathXmlApplicationContext — it used to be the most common way of context creation a few years before. This implementation consumes a path to the XML file that describes the beans to be created for the context.
  • AnnotationConfigApplicationContext — this one reads the configuration from Java annotations for the same purposes instead of reading an XML file.

--

--