报错:
Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy5 cannot be cast to aopAnnotation.UserDaoImp
at aopAnnotation.testmain.main(testmain.java:18)
解决:
去掉 @serivce,因为这路径还没有把com.zx.aop.AirthmeticDaoImp包含在内,就开始执行了
或者把<aop:aspectj-autoproxy/> 修改成<aop:aspectj-autoproxy proxy-target-class="true"/>
容器注入:一般包括这几个文件
user.java Bean
UserDao.java interfice
UserDaoImp.java
*.xml <bean id ="userDao" class="*.*.*.*.UserDaoImp">
main.java : UserDao ud=(UserDao) new classPathXmlApplicationContext("userDao"); ud.function();
参考:https://blog.csdn.net/zx6571269/article/details/79330495