类 AnnotationConfigApplicationContext

所有已实现的接口:
BeanFactory, HierarchicalBeanFactory, BeanDefinitionRegistry, DependencyInjectorProvider, AnnotationConfigRegistry, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, cn.taketoday.core.AliasRegistry, cn.taketoday.core.env.EnvironmentCapable, cn.taketoday.core.io.PatternResourceLoader, cn.taketoday.core.io.ResourceLoader, Closeable, AutoCloseable

public class AnnotationConfigApplicationContext extends StandardApplicationContext
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 StandardApplicationContext.register(Class...) as well as for classpath scanning using StandardApplicationContext.scan(String...).

In case of multiple @Configuration classes, @Component 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.

从以下版本开始:
4.0 2022/2/20 21:24
作者:
Juergen Hoeller, Chris Beams, Harry Yang
另请参阅:
  • 构造器详细资料

    • AnnotationConfigApplicationContext

      public AnnotationConfigApplicationContext()
      Create a new AnnotationConfigApplicationContext that needs to be populated through StandardApplicationContext.register(java.lang.Class<?>...) calls and then manually refreshed.
    • AnnotationConfigApplicationContext

      public AnnotationConfigApplicationContext(StandardBeanFactory beanFactory)
      Create a new AnnotationConfigApplicationContext with the given DefaultListableBeanFactory.
      参数:
      beanFactory - the DefaultListableBeanFactory instance to use for this context
    • AnnotationConfigApplicationContext

      public AnnotationConfigApplicationContext(@Nullable ApplicationContext parent)
    • AnnotationConfigApplicationContext

      public AnnotationConfigApplicationContext(StandardBeanFactory beanFactory, ApplicationContext parent)
    • AnnotationConfigApplicationContext

      public AnnotationConfigApplicationContext(Class<?>... components)
      Create a new AnnotationConfigApplicationContext, deriving bean definitions from the given component classes and automatically refreshing the context.
      参数:
      components - one or more component classes — for example, @Configuration classes
    • AnnotationConfigApplicationContext

      public AnnotationConfigApplicationContext(String... basePackages)
      Create a new AnnotationConfigApplicationContext, scanning for components in the given packages, registering bean definitions for those components, and automatically refreshing the context.
      参数:
      basePackages - the packages to scan for component classes