20171219_spring aop报错:Cannot proxy target class because CGLIB2 is not available

spring aop报错:Cannot proxy target class because CGLIB2 is not available.

 

今天在通过SApring AOP实现log4j时遇到问题:

Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy7 implementing com.passing.spring.service.SearchEnToCn,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'com.passing.spring.service.impl.SearchEnToCnBean' for property 'searchEnToCnBean'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy7 implementing com.passing.spring.service.SearchEnToCn,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.passing.spring.service.impl.SearchEnToCnBean] for property 'searchEnToCnBean': no matching editors or conversion strategy found

 

网上搜了一下,结合了不同的解决方法后总结了一下

解决方法:

com.ideal.service.impl.UserServiceImpl实现的是com.ideal.service.interfaces.UserService接口,由于spring实现的是接口注入,关联的实现类。这里实现注入类,所以出现了异常。

在spring配置文件加入以下代码,实现类注入

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

之后又遇到问题:

Caused by: org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.

解决方法:

导入cglib-nodep-2.1_3.jar包(不能是cglib-nodep-2.2.jar,或者导入asm-2.2.3.jar和cglib-2.2.jar )

OK,问题解决

对了,我用的是spring3.0.1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值