spring aop异常
Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]:
问题:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
在使用Spring的AOP编程时,会用到这几个lib:(版本不一样,文件名也不一样)
asm-2.2.3.jar
asm-commons-2.2.3.jar
asm-util-2.2.3.jar
Hibernate使用如下lib:
asm.jar
asm-attrs.jar
其中asm-2.2.3.jar与asm.jar存在类上的冲突!
解决办法是:
1.去掉类路径上的关于Hibernate的3个lib
asm.jar
asm-attrs.jar
cglib-2.1.3.jar
2.加入Spring中的以下4个lib
asm-2.2.3.jar
asm-commons-2.2.3.jar
asm-util-2.2.3.jar
cglib-nodep-2.1_3.jar