控制台输出:
[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类应该为接口,而不是接口的实现类。