spring强制cglib代理不起作用?附异常信息

amss 发布于 2013/06/13 20:37
阅读 1K+
收藏 0

配置了强制使用cglib,但spring还是使用JDK代理service,所有的service都实现了IGenericService接口,而且在有注入bean的地方,会报错

Cannot convert value of type [$Proxy10 implementing org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,net.sf.cglib.proxy.Factory,com.xxx.service.IGenericService] to required type [com.xxx.service.impl.UserService] for property 'userService': no matching editors or conversion strategy found

aop的配置:使用的是cglib-nodep-2.1_3.jar,spring3.1.4

<aop:aspectj-autoproxy proxy-target-class="true"/>  

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
       <tx:method name="get*" read-only="true" />
       <tx:method name="find*" read-only="true" />
       <tx:method name="*" rollback-for="Exception" />
</tx:attributes>
</tx:advice>
    <aop:config proxy-target-class="true" >
<aop:pointcut id="serviceMethod"
expression="execution(* com.xxx.service.impl..*Service.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod" />
</aop:config>

折腾一天了,不知道问题出在哪里,求指点

异常信息:

Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy10 implementing org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,net.sf.cglib.proxy.Factory,xxxxx.service.IGenericService' to required type 'xxxx.service.impl.UserService' for property 'userService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy10 implementing org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,net.sf.cglib.proxy.Factory,xxxxx.service.IGenericService] to required type [xxxxx.service.impl.UserService] for property 'userService': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1406)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1365)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 88 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy10 implementing org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,net.sf.cglib.proxy.Factory,xxxxx.service.IGenericService] to required type [xxxx.service.impl.UserService] for property 'userService': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:247)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470)
... 94 more


加载中
0
a
amss
找到问题了,是配置了shiro的关系,得到shiro区提问了
返回顶部
顶部