A Quick Guide to Spring Beans

Java beans? Nah Spring beans

JT Earl
6 min readNov 16, 2020

What is Spring?

Spring is a lightweight framework for Java often used in, but not limited to, enterprise development. Spring is modular, meaning you only need to pull in the packages you use. Spring has several groups of modules Core, Web, Data Access, and Miscellaneous. Spring enables inversion of control(IoC) by using dependency injection(DI), this decouples the code and makes testing easier. The ease of DI is often seen as the biggest benefit of using Spring. Spring has some framework-specific terms, one of the most common terms used is a bean.

Photo by Boris Smokrovic on Unsplash

What is a Spring Bean?

Containers

Before learning about beans let’s look at the containers that use them. The Spring container takes a Java class and some configuration metadata and creates an application. Components passed to the container are Spring Beans. The metadata provided to the container can get set in three different ways: XML, annotations, and Java. Annotations are the ones I see most in my enterprise work environment. There are two types of containers in Spring: BeanFactory and ApplicationContext. Bean factory is an older lightweight container that provides backward compatibility. The ApplicationContext container has all the functionality of BeanFactory and…

--

--

JT Earl

Programmer Since 17. Currently working in front-end and mid-tier programming for a finance company. Check out my Tech blog @ documentobject.com