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 ...
随机推荐
- Java系列笔记(3) - Java 内存区域和GC机制
目录 Java垃圾回收概况 Java内存区域 Java对象的访问方式 Java内存分配机制 Java GC机制 垃圾收集器 Java垃圾回收概况 Java GC(Garbage Collection, ...
- C#的反射机制
using System; using System.Collections; using System.Collections.Generic; using System.IO; using Sys ...
- Android 注解工具 ButterKnife
Butter Knife 是 Android 视图字段和方法绑定,使用注解处理来生成样板代码. 主要特性: 在字段使用 @FindView消除findViewById调用 使用 @FindViews在 ...
- 【转载】Pyqt 编写的俄罗斯方块
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function from __future__ ...
- Pyqt QTabWidget 简单的计算器集合
今天我们简单介绍下QTabWidget,然后在加入Demo计算器 首先我先讲下文件的结构: 文件分四部分, 一部分是Ui设计文件, 一部分是由Ui生成的py文件, 一部分是 计算器的逻辑文件, 最后 ...
- poj 2524:Ubiquitous Religions(并查集,入门题)
Ubiquitous Religions Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 23997 Accepted: ...
- FTP的20、21端口,工作模式
什么是FTP? FTP就是文件传输协议 File Transfer Protocol 的缩写. FTP端口号是多少? 21 FTP的端口号能改吗? 能 ftp的端口号20.21有何区别? 一个是数据端 ...
- 运维自动化之ansible的安装与使用(包括模块与playbook使用)(转发)
原文 http://dl528888.blog.51cto.com/2382721/1435415 我使用过puppet(地址是http://dl528888.blog.51cto.com/2382 ...
- MS SQL 合并结果集并求和 分类: SQL Server 数据库 2015-02-13 10:59 92人阅读 评论(0) 收藏
业务情景:有这样一张表:其中Id列为表主键,Name为用户名,State为记录的状态值,Note为状态的说明,方便阅读. 需求描述:需要查询出这样的结果:某个人某种状态的记录数,如:张三,待审核记录数 ...
- Golang gopath
golang 的gopath 至关重要,会影响到我们import package. golang 支持以相对路径的方式import,但是这种方式是不推荐的. 推荐的做法是在gopath中添加我们的项目 ...