问题描述
今天在整合spring aop时报了这个错:Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpwordDao' defined in ServletContext resource [/WEB-INF/config/spring/data-access-config.xml]: Initialization of bean failed; nested exception is 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.2.jar 但是将其加入到buildpath中后还是报同一个错误,估计可能是Spring中的cglib-nodep-2.x.x.jar与Hibernate中的cglib-2.2.jar相冲突,这时需要保留spring的,取消hibernate的,但是查了一遍lib,没有发现hibernate的cglib-2.2.jar,这就不懂是什么情况了,请问谁知道是怎么回事
解决方案
嗯! 你已经找到问题所在了!cglib jar版本 和 你框架的 版本问题! 你看下官方推荐的版本 或者 换更高的版本咯!我们现在项目:spring3.1 使用的 是:cglib-nodep-2.1_3.jar
解决方案二:
导入cglib-nodep-2.1_3.jar包,或者导入asm-2.2.3.jar和cglib-2.2.jar