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 ...
随机推荐
- Xcode开发中的6个小技巧
Xcode是iPhone和iPad开发者用来编码或者开发iOS app的IDE.Xcode有很多小巧但很有用的功能,很多时候我们可能没有注意到它们,也或者我们没有在合适的水平使用这些功能简化我们的iO ...
- java 小数点处理
public class Test { public static void main(String[] args) { double i = 3.856; // 舍掉小数取整 System.out. ...
- Asp.Net - 9.socket(聊天室)
9.1 Socket相关概念 IP地址 每台联网的电脑都有一个唯一的IP地址. 长度32位,分为四段,每段8位,用十进制数字表示,每段范围 0 ~ 255 特殊IP:127.0.0.1 用户本地网卡测 ...
- Kl 证明 凸函数
回到随机变量传输问题,假设传输中我们不知道具体 分布情况(unknown),我们用一个已知的分布 ,来模拟它,那么在这种情况下如果我们利用 尽可能高效的编码,那么我们平均需要多少额外的信息量来描述x呢 ...
- 重温WCF之WCF传输安全(十三)(4)基于SSL的WCF对客户端采用证书验证(转)
转载地址:http://www.cnblogs.com/lxblog/archive/2012/09/20/2695397.html 前一篇我们演示了基于SSL的WCF 对客户端进行用户名和密码方式的 ...
- WCF分布式开发必备知识(3):Web Service 使用
参考地址:http://www.cnblogs.com/zhili/p/WebService.html 一.WebService概述 SOAP.WSDL.UDDISOAP(Simple Object ...
- Bootstrap 表格 笔记
Bootstrap 表格 Bootstrap 提供了一个清晰的创建表格的布局.下表列出了 Bootstrap 支持的一些表格元素: 标签 描述 <table> 为表格添加基础样式. < ...
- Spring XML配置文件示例(二)——web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" ...
- 获得H.264视频分辨率的方法
转自:http://www.cnblogs.com/likwo/p/3531241.html 在使用ffmpeg解码播放TS流的时候(例如之前写过的UDP组播流),在连接时往往需要耗费大量时间.经过d ...
- PMP 第二章 项目生命周期与组织
1 项目组织机构类型有哪些? 区别是什么? 职能型 矩阵型 项目性 2 什么是事业环境因素? 什么是组织过程资产? 如何区分事业环境因素和组织过程资产? 事业环境因素:事业环境因素指围绕项目或能影 ...