ImportSelector:返回需要导入的组件的全类名数组
创建一个实现了ImportSelector接口的类,然后让入Import中。ImportSelector的实现类包含了所有需要导入到容器中的组件
@Configuration @ComponentScan("com.yyc") @Import({Person.class, MyImportSelector.class}) public class MainConfig2 {
public class MyImportSelector implements ImportSelector { public String[] selectImports(AnnotationMetadata importingClassMetadata) { return new String[] {}; } }