Class AnnotationConfigApplicationContext

java.lang.Object
org.springframework.core.io.DefaultResourceLoader
All Implemented Interfaces:
Closeable, AutoCloseable, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.ListableBeanFactory, org.springframework.beans.factory.support.BeanDefinitionRegistry, AnnotationConfigRegistry, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, org.springframework.core.AliasRegistry, org.springframework.core.env.EnvironmentCapable, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver

public class AnnotationConfigApplicationContext extends GenericApplicationContext implements AnnotationConfigRegistry
Standalone application context, accepting component classes as input — in particular @Configuration-annotated classes, but also plain @Component types and JSR-330 compliant classes using jakarta.inject annotations.

Allows for registering classes one by one using register(Class...) as well as for classpath scanning using scan(String...).

In case of multiple @Configuration classes, @Bean methods defined in later classes will override those defined in earlier classes. This can be leveraged to deliberately override certain bean definitions via an extra @Configuration class.

See @Configuration's javadoc for usage examples.

Since:
3.0
Author:
Juergen Hoeller, Chris Beams
See Also: