Cannot proxy target class because CGLIB2 is not available

Cannot proxy target class because CGLIB2 is not available y: org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
at org.springframework.aop.framework.DefaultAopProxyFactory.createAopProxy(DefaultAopProxyFactory.java:67)
at org.springframework.aop.framework.ProxyCreatorSupport.createAopProxy(ProxyCreatorSupport.java:106)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:490)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:365)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:361)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1344)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
... 38 more



解决方法:
1.缺少CGlib,把CGLIB Jar包放入项目就可以了.
2. 没有实现任何接口的时候也会报这个错误!
注:cglib不包含asm,cglib-nodep包含了asm,而asm是cglib必须的三方类库,出现两个版本的原因恐怕是要避免框架集成时的版本冲突吧。
======================================================================
Cannot convert value of type [$Proxy0 implementing org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [dao.UserDaoImp] for property 'userDao': no matching editors or conversion strategy found
就异常显示的信息可以看到,Spring在转换时,主要是将代理类转换成接口,而不能转换成实际类。
解决办法:
1.如果在Spring配置文件中配置的事务是通过AOP标签实现的,那就在<aop:config />中增加proxy-target-class="true"属性。
2.使实际的类实现某个接口(UserDaoImp实现UserDao接口)

猜你喜欢

转载自vanessa-rain.iteye.com/blog/2015066