zoukankan      html  css  js  c++  java
  • Aop配置时候的一些问题

    编写切面,并在ApplicationContest.xml 中相关AOP及切面的配置完全正确的情况下,运行报错如下:

    Exception in thread "main" org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'usd' is expected to be of type 'com.yusys.service.UserServiceImpl' but was actually of type 'com.sun.proxy.$Proxy2'
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:378)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1086)
    at com.yusys.test.Test.main(Test.java:14)

    解决办法是,在AppliacationContext.xml中添加 <aop:aspectj-autoproxy  proxy-target-class="true"/> 这样的配置即可解决

    多次搜索获得的一个解释是:如果切入点切入的是实现类需要在spring的配置文件中加上<aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>标签,代表代理的实现类而非基于接口代理

    本博主支持并坚持原创,本博客文章将以原创为主。
  • 相关阅读:
    单例
    ASIHttpRequest加载网络数据和上传数据功能
    JSONModel
    KVC/KVO
    C中的动态内存分配和释放(free)
    IOS开发中Xcode一些使用技巧,快捷键的使用
    Struts2文件上传
    Struts2的输入校验
    struts2类型转换中的错误处理
    struts2自定义类型转换器
  • 原文地址:https://www.cnblogs.com/xiaoyao-001/p/8098546.html
Copyright © 2011-2022 走看看