Spring AOP报错处理 Can not set field to $Proxy 在spring中使用事物或AOP遇到的错误
【转】
解决方法:
在配置文件中加入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遇到的错误的更多相关文章
- 解决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 ...
- Spring Boot报错 MultipartException The temporary upload...
Spring Boot报错:尤其是在处理Ribbon这类接口调用型的负载均衡组件,常见问题 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.se ...
- 项目中访问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 ...
- Spring Boot 报错记录
Spring Boot 报错记录 由于新建的项目没有配置数据库连接启动报错,可以通过取消自动数据源自动配置来解决 解决方案1: @SpringBootApplication(exclude = Dat ...
- 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 ...
- vs2010一运行就报错deven.exe assert failure 解决方法,卸载系统中.netFramework最新版本的(简体中文)
vs2010一运行就报错deven.exe assert failure 解决方法,卸载系统中.netFramework最新版本的(简体中文)
- Spring AOP报错
八月 01, 2016 10:08:48 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRe ...
- 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 ...
- spring boot aop 报错
1.控制台报错 Pointcut is not well-formed: expecting 'name pattern' at character position 33 execution(com ...
随机推荐
- 使用xib需要记得的小问题
1. 图片 加载 图片上的label 不显示, 最后是因为xib 里位置动了 图片跑到最上层盖住了labe 2. 加载xib 有时候会崩 或加载不出来 先查看xib 是否有多余控件 3. 查看关联 ...
- JS中级 - 01:DOM节点
1元素属性 1.1childNodes 返回元素的一个子节点的数组 (不推荐,建议用非标准children代替) 提醒:只包含一级子节点,不包含后辈孙级别以下节点. children:返回元素的一 ...
- Jcapta
http://blog.csdn.net/shadowsick/article/details/8575471
- Linux进程状态 ( Linux Process State Codes)
进程状态代码及说明: STATE代码 说明 D 不可中断的睡眠. 通常是处于I/O之中. R 运行中/可运行. 正处于运行队列中. S 可中断的睡眠. 等待某事件发生. T 已停止. 可能是因为she ...
- Liunx-https-java.lang.NoClassDefFoundError: javax/crypto/SunJCE_b
错误信息: java.lang.NoClassDefFoundError: javax/crypto/SunJCE_b at javax.crypto.KeyGenerator.a(DashoA13* ...
- uint8_t / uint16_t / uint32_t /uint64_t 是什么数据类型 - 大总结,看完全明白了
转自:http://blog.csdn.net/kiddy19850221/article/details/6655066 uint8_t / uint16_t / uint32_t /uint64_ ...
- vim用法小节
1.把一个文件的内容全选复制到另一个文件 方案一: gg"*yG 然后另外一个vim "*p "*是系统剪贴板寄存器 方案二: 打开另一个文件,然后输入 :r filen ...
- Linux下常用命令
1.判断桌面环境是Gnome还是KDE #update-alternatives --display x-session-manager
- VR 相关专业词汇
最近在看 SIGGRAPH2015 有关 VR Display and Interaction 的几篇文章,之前从来没看过有关方面的 paper,一看才发现专业词汇太多了,根本不懂啊,幸亏 Paper ...
- I/O复用模型之select学习
linux下的I/O模型可以分为5种: 1.阻塞式I/O模型 2.非阻塞式I/O模型 3.I/O复用模型 4.信号驱动I/O模型 5.异步I/O模型 简单解释: 阻塞和非阻塞:就是说需要做一件事的时候 ...