注释类型 Import
@Target(TYPE) @Retention(RUNTIME) @Documented public @interface Import
Indicates one or more@Configurationclasses to import.Provides functionality equivalent to the
<import/>element in Spring XML. Allows for importing@Configurationclasses,ImportSelectorandImportBeanDefinitionRegistrarimplementations, as well as regular component classes (as of 4.2; analogous toAnnotationConfigApplicationContext.register(java.lang.Class<?>...)).@Beandefinitions declared in imported@Configurationclasses should be accessed by using@Autowiredinjection. Either the bean itself can be autowired, or the configuration class instance declaring the bean can be autowired. The latter approach allows for explicit, IDE-friendly navigation between@Configurationclass methods.May be declared at the class level or as a meta-annotation.
If XML or other non-
@Configurationbean definition resources need to be imported, use the@ImportResourceannotation instead.- 从以下版本开始:
- 3.0
- 作者:
- Chris Beams, Juergen Hoeller
- 另请参阅:
Configuration,ImportSelector,ImportResource
必需元素概要
所需元素 修饰符和类型 必需的元素 说明 Class<?>[]valueConfiguration,ImportSelector,ImportBeanDefinitionRegistraror regular component classes to import.
元素详细资料
value
Class<?>[] value
Configuration,ImportSelector,ImportBeanDefinitionRegistraror regular component classes to import.