Spring中Can not set field to $Proxy 报错解决
2017-03-14 14:17
531 查看
问题: 在spring相关项目启动的时候,报错相关内容为Can not set field to $Proxy。
原因:因为JDK实现动态代理业务的时候,只能针对接口进行定义。然而对于类需要进行代理,需要使用到CGLib。CGLib采用了非常底层的字节码技术,其原理是通过字节码技术为一个类创建子类,并在子类中采用方法拦截的技术拦截所有父类方法的调用,顺势织入横切逻辑。JDK动态代理与CGLib动态代理均是实现Spring AOP的基础。正是由于在代码中使用了类代理,但是配置不正确,所以报错。
解决方法:在XML配置文件中加入 proxy-target-class=”true” 配置。例如:
或者
原因:因为JDK实现动态代理业务的时候,只能针对接口进行定义。然而对于类需要进行代理,需要使用到CGLib。CGLib采用了非常底层的字节码技术,其原理是通过字节码技术为一个类创建子类,并在子类中采用方法拦截的技术拦截所有父类方法的调用,顺势织入横切逻辑。JDK动态代理与CGLib动态代理均是实现Spring AOP的基础。正是由于在代码中使用了类代理,但是配置不正确,所以报错。
解决方法:在XML配置文件中加入 proxy-target-class=”true” 配置。例如:
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
或者
<aop:config proxy-target-class="true">
相关文章推荐
- spring transaction 注解方法报错Can not set field to proxy
- 【spring】IllegalArgumentException Can not set field to $Proxy 在spring中使用事物或AOP遇到的错误
- 【spring】IllegalArgumentException Can not set field to $Proxy 在spring中使用事物或AOP遇到的错误
- spring transaction 注解方法报错Can not set field to proxy
- Spring AOP报错处理 Can not set field to $Proxy 在spring中使用事物或AOP遇到的错误
- Caused by: java.lang.IllegalArgumentException: Can not set int field reyo.sdk.enity.xxx.xxx to java.lang.Long
- Can not set int field entity.Authority.FatherAuthority to null value
- 解决[SetAllPropertiesRule]{Server/Service/Connector} Setting property 'maxTheads' to '500' did not fin
- Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name. 的解决方法
- Can not run Dotfuscator 4.4-----Reference not set to an object.
- Can not connect to local MySQL server through socket 解决办法
- VS2005 solution文件打开时弹出“object reference not set to an instance of an object”错误的解决方法
- Can not write to cache files, please check directory ./data/ and ./data/cache/ . 的解决方法
- spring.net Could not initialize proxy - the owning Session was closed 解决
- silverlight项目出现object reference not set to an instance of an object的解决办法
- Can not find the tag library descriptor for "http://www.springframework.org/tags/form" 解决方法
- 【转】Vmware ESX 3.0出现“error connecting: can not connect to host x.x.x.x: a connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed……的解决方法
- silverlight beta2.0安装成功后新建silverlight项目出现object reference not set to an instance of an object的解决办法
- ERROR: Unable to launch the RTL Schematic process. The input NGR file, Can not fnd the module的解决方法
- SQLServer2005打开表时出现“Object reference not set to an instance of an object. (SQLEditors)”错误的解决办法