@DirtiesContext

Опубликовано: 25 Март 2026
на канале: JavaAnatomy
206
3

If we don’t want to cache a context, we want a new context for any reason,
We can tell spring to close and destroy the Application Context and create a new one.

@DirtiesContext at method level or class level.

Test annotation which indicates that the ApplicationContext associated with a test is dirty and should therefore be closed and removed from the context cache.