解决方法: 1.主程序加扫面注解 @ComponentScan("cn.test") //包的路径 2.不使用注解引入使用ApplicationContext 通过applicationContext和反射机制来获取对象