Andrez Segovia

Spring Framework (3)

The @DirtiesContext Spring Annotation

In some test scenarios, a Spring Bean can become corrupted, causing other test scenarios to fail. To prevent this, we can annotate a test class or test method with @DirtiesContext, which tells the Spring Framework that the ApplicationContext is dirty, forcing the rebuilding of the Spring container and creating a new bean instances.

Working with Beans in Spring Framework

A JavaBean is a standard Java class with getter/setter methods, a no-arg constructor, and is serializable. And a Spring Bean is any Java object managed by Spring and can be automatically injected into other components. The Spring Dependency injection allows Spring to manage and inject beans where needed.

March 27, 2025

I’ve been learning more about testing spring boot application. I had tested spring boot applications before, but I had only used some basic features. Now, I would like to go deeper to explore what interesting things can be done with it.