@Import 导入某个bean 文件 @Configuration @Import({User.class,MyImportSelector.class,MyImportBeanDefinitionRegistrar.class}) public class ImportConfig { @Bean public Person getPerson(){ return new Person(); } } Selector //自定义逻辑返回需要导入的组件 public class MyImpo…
转自:https://blog.csdn.net/heyutao007/article/details/74994161 @Import注解就是之前xml配置中的import标签,可以用于依赖第三方包中bean的配置和加载在4.2之前只支持导入配置类在4.2,@Import注解支持导入普通的java类,并将其声明成一个bean public class DemoService { public void doSomething(){ System.out.println("ok");…