【转】

解决方法:

http://forum.springsource.org/showthread.php?85016-IllegalArgumentException-with-ApplicationContextAware-Proxy

在配置文件中加入proxy-target-class="true"

<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>

或者:

<aop:config proxy-target-class="true">

现在我的配置文件如下:

<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<!-- 配置事务管理器 -->
<bean
id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name="sessionFactory" >
<ref local="sessionFactory" />
</property>
</bean>
<!-- 配置哪些方法需要哪些事务 -->
<tx:advice
id="txadvice"
transaction-manager="transactionManager" >
<tx:attributes>
<tx:method
name="create*"
propagation="REQUIRED" />
<tx:method
name="delete*"
propagation="REQUIRED" />
<tx:method
name="update*"
propagation="REQUIRED" />
<tx:method name="read*"
read-only="true"
propagation="NOT_SUPPORTED"/>
<tx:method
name="*"
read-only="true" />
</tx:attributes>
</tx:advice>
<!-- pointcut切入点;advice,通知,即被织入的方法 。这儿是AOP-->
<aop:config proxy-target-class="true">
<aop:pointcut
id="managerMethods"
expression="execution (* org.ccnt.med.dao.TbTopicDao.*(..))" />
<aop:pointcut
id="managerMethods"
expression="execution (* org.ccnt.med.dao.TbDisTopicDao.*(..))" />
<aop:advisor
advice-ref="txadvice"
pointcut-ref="managerMethods" />
</aop:config>

解释:

AOP使用的动态代理可以针对接口,也可以针对类。java的动态代理只能针对接口。

在用Spring的AOP时,默认动态代理是针对接口的,而我用的是针对类的,所以要加上proxy-target-class="true"

Spring AOP报错处理 Can not set field to $Proxy 在spring中使用事物或AOP遇到的错误的更多相关文章

  1. 解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element

    解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element 'beans'.Referenced file conta ...

  2. Spring Boot报错 MultipartException The temporary upload...

    Spring Boot报错:尤其是在处理Ribbon这类接口调用型的负载均衡组件,常见问题 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.se ...

  3. 项目中访问controller报错:HTTP Status 500 - Servlet.init() for servlet spring threw exception

    直接访问controller路径http://localhost:8080/index报错: HTTP Status 500 - Servlet.init() for servlet spring t ...

  4. Spring Boot 报错记录

    Spring Boot 报错记录 由于新建的项目没有配置数据库连接启动报错,可以通过取消自动数据源自动配置来解决 解决方案1: @SpringBootApplication(exclude = Dat ...

  5. Spring.之.报错:Caused by: java.lang.IllegalArgumentException: No Spring Session store is configured: set the 'spring.session.store-type' property

    Spring.之.报错 No Spring Session store is configured springboot在启动的时候报如下错误: Error starting ApplicationC ...

  6. vs2010一运行就报错deven.exe assert failure 解决方法,卸载系统中.netFramework最新版本的(简体中文)

    vs2010一运行就报错deven.exe assert failure 解决方法,卸载系统中.netFramework最新版本的(简体中文)

  7. Spring AOP报错

    八月 01, 2016 10:08:48 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRe ...

  8. Spring AOP 报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXXXXX' defined in class path resource..........

    完整报错如下: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'befo ...

  9. spring boot aop 报错

    1.控制台报错 Pointcut is not well-formed: expecting 'name pattern' at character position 33 execution(com ...

随机推荐

  1. Swift - 让程序挂起后,能在后台继续运行任务

    1,程序的挂起和退出 由于iOS设备资源有限.当用户点击了home键,或者另一个应用程序启动了.那么原先那个程序便进入后台被挂起,不是退出,只是停止执行代码,同时它的内存被锁定.当应用程序恢复时,它会 ...

  2. JDK、Jmeter、Android环境变量配置

    JDK环境变量 1.在系统变量里点击新建,变量名填写JAVA_HOME,变量值填写JDK的安装路径,在这里就填写"D:\Program Files\Java\jdk1.6.0_26" ...

  3. mysql列类型

    mysql三大列类型 整型 tinyint(占据空间:1个字节 存储范围  有符号  -128-127   无符号  0-255) smallint   mediumint    int    big ...

  4. CLR via C#(05)- 访问限定、数据成员

    今天跟大家分享一下关于访问限定和数据成员的知识.主要包括以下两点: Abstract, sealed, virtual, new, override怎么用? Const 和 readonly好像都表示 ...

  5. 【C#】Json数据 排版算法

    我从服务器上取得一串Json数据,然后想表示到画面上.不过服务器上取下的Json数据肯定是经过压缩的,空格和换行都没有.如果直接看,可读性非常差. 由于我这个软件是内部管理用的,使用者既能直接看懂Js ...

  6. 【翻译十】java-固定锁和同步

    Intrinsic Locks and Synchronization Synchronization is built around an internal entity known as the  ...

  7. POJ2406 Power Strings(KMP,后缀数组)

    这题可以用后缀数组,KMP方法做 后缀数组做法开始想不出来,看的题解,方法是枚举串长len的约数k,看lcp(suffix(0), suffix(k))的长度是否为n- k ,若为真则len / k即 ...

  8. 用康托展开实现全排列(STL、itertools)

    康拓展开: $X=a_n*(n-1)!+a_{n-1}*(n-2)!+\ldots +a_2*1!+a_1*0!$ X=an*(n-1)!+an-1*(n-2)!+...+ai*(i-1)!+...+ ...

  9. Linux系统安装及初始化(ubuntu14.04)

    Windows 7下硬盘安装Ubuntu 14.04图文教程 Ubuntu 官方已经发布了正式版的 Ubuntu 14.04 LTS,并宣称这是为云计算准备的版本.该版本在云平台和伸缩环境的可靠性.性 ...

  10. VS2012 配置 OpenCV3.0

    VS2012 配置 opencv3.0,相比之前的版本,3.0的配置简单了好多. 通过配置属性文件,可以做到一次配置,重复使用! 根据文章的操作在 win7 64bit VS2012 下成功配置 op ...