在xml配置文件中配置的bean 在springboot中是无法正常使用的,因为用的不是这个方法了
ApplicationContext ctx= new ClassPathXmlApplicationContext("bean.xml");
在springboot中用的
SpringApplication.run(App.class, args);
要中springboot中使用原来的xml配置的bean 就需要使用@ImportResource
@ImportResource("classpath:beans.xml") // public class MyConfig {}======================测试=================boolean haha = run.containsBean("haha");boolean hehe = run.containsBean("hehe");System.out.println("haha:"+haha);//trueSystem.out.println("hehe:"+hehe);//true
@ImportResource("classpath:beans.xml") 中配置类上 加上这个注解 指定spring的xml 就自动加入容器了