当前位置:编程学习 > JAVA >>

spring AOP事物配置启动报错

配置文件中加了:
<?xml version="1.0" encoding="UTF-8"?>
<!-- <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">    -->

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:config="http://www.springframework.org/schema/config"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
                    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">




<!-- 配置那些类的方法进行事务管理 -->
 <aop:config proxy-target-class="true"> 
  <aop:pointcut id="allBOMethod" expression="execution(* gov.hebcz.nontax.bo..*.*(..))"/>
  <aop:advisor advice-ref="interfaceAOP" pointcut-ref="allBOMethod" />
 </aop:config>


启动报错:java.lang.IllegalArgumentException: Cannot subclass final class class $Proxy50
但是把proxy-target-class="true"去掉之后,报另一个错:java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy51 implementing org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [gov.hebcz.nontax.util.SeqProc] for property 'seqProc': no matching editors or conversion strategy found,求解,困扰很长时间了,现在还没有分,抱歉,求助……



Spring AOP --------------------编程问答-------------------- 官方文档里的解析,希望能帮到你。 --------------------编程问答-------------------- 启动报错:java.lang.IllegalArgumentException: Cannot subclass final class class $Proxy50
* gov.hebcz.nontax.bo这个包中的class 有定义成final的,导致做代理类的时候不能实现。已经很明显了

java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy51 implementing org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [gov.hebcz.nontax.util.SeqProc] for property 'seqProc': no matching editors or conversion strategy found

去掉以后是不是用cglib来做代理,而是使用jdk的Proxy.newProxyInstance来做代理,是需要接口的,
此段错误的翻译是 在设置字段seqProc的时候, 不能将已经生成的代理类$Proxy51转化为gov.hebcz.nontax.util.SeqProc这种类型,因为代理类实现的是org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised这些接口,而需要的类型是gov.hebcz.nontax.util.SeqProc这个。

想确认的问题
1 想做aop的java service bean有没有实现接口.
2 如果没有的话,还是用cglib来做,检查一下final的关键字。
--------------------编程问答-------------------- 高手,您能帮我看看吗,不太知道怎么整,spring AOP事物配置这块儿不太了解…… --------------------编程问答-------------------- 把配置文件和代码贴全了看看哪里有这个不当转换成gov.hebcz.nontax.util.SeqProc
或者final类的存在 --------------------编程问答-------------------- 来我博客参考ehcache的使用的aop...
补充:Java ,  Java相关
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,