今天遇到spring的注入问题,看半天以为是spring的注入失败,其实是以为注入的对象不能以传统模式即new方式取得。
可以使用
ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");
StudentService service = (StudentService) app.getBean("studentService");
今天遇到spring的注入问题,看半天以为是spring的注入失败,其实是以为注入的对象不能以传统模式即new方式取得。
可以使用
ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");
StudentService service = (StudentService) app.getBean("studentService");