クラス AnnotationConfigApplicationContext

実装されたすべてのインターフェース:
CloseableSEAutoCloseableSEBeanFactoryHierarchicalBeanFactoryListableBeanFactoryBeanDefinitionRegistryAnnotationConfigRegistryApplicationContextApplicationEventPublisherConfigurableApplicationContextLifecycleMessageSourceAliasRegistryEnvironmentCapableResourceLoaderResourcePatternResolver

public class AnnotationConfigApplicationContext extends GenericApplicationContext implements AnnotationConfigRegistry
コンポーネントクラスを入力として受け入れるスタンドアロンアプリケーションコンテキスト — 特に @Configuration アノテーション付きクラスだけでなく、プレーン @Component 型および jakarta.inject アノテーションを使用する JSR-330 準拠クラスも受け入れます。

register(Class...) を使用してクラスを 1 つずつ登録し、scan(String...) を使用してクラスパスをスキャンできます。

複数の @Configuration クラスの場合、後のクラスで定義された @Bean メソッドは、前のクラスで定義されたメソッドをオーバーライドします。これを活用して、追加の @Configuration クラスを介して特定の Bean 定義を意図的にオーバーライドできます。

使用例については、@Configuration の javadoc を参照してください。

導入:
3.0
作成者:
Juergen Hoeller, Chris Beams
関連事項: