基于aspectjwear方式开启aop
今天刷到b站视频,看到aop织入,发现有点忘了。pom导入aspectjwear依赖,配置spring-aop.xml后引入context aop context扫描包aspect 开启aop自动识别。在切面类方法中配置切入点,测试发生以下错误。
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'booksmapimpl' is expected to be of type 'com.liu.service.BooksMapImpl' but was actually of type 'com.sun.proxy.$Proxy31'
代理类问题,需要在开始aop自动识别配置中加入
proxy-target-class="true" 启用cglib代理方式 奇怪啊,我使用的是基于aspectj织入的代理。
猜测:
cglib是基于实现类的代理,我在spring-service.xml中配置的这个实现类的bean,所以要使用基于实现类的代理实现。
posted on 2023-05-07 21:53 ゆらめく心に満ちた世界で 阅读(23) 评论(0) 收藏 举报
 
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号