Spring常见问题整理(持续更新)

1.常见错误一
控制台输出:
[ERROR] java.lang.ClassCastException: $Proxy2 cannot be cast to com.jin.bbs.user.UserManagerImpl  

原因:
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); 
UserManagerImpl userManagerImpl = (UserManagerImpl) getBean("userManager"); 

当通过上面代码调用类方法时,需要特别注意,Spring只能对接口AOP,此处UserManagerImpl类应该为接口,而不是接口的实现类。

猜你喜欢

转载自yimengdaotianming.iteye.com/blog/1221046
今日推荐