您的位置:首页 > 编程语言 > Java开发

org.springframework.beans.factory.BeanNotOfRequiredTypeException

2013-03-26 00:15 459 查看
整合spring和hibernate时老是遇上这个错误,查了半天找到了问题所在,现在还不是太了解,先贴出来,慢慢研究

写Junit测试类的时候

错误写法:

ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");		
UserService us = applicationContext.getBean("userService",UserServiceImpl.class);


正确的写法:

ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");		
UserService us = applicationContext.getBean("userService",UserService.class);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐