初学spring,在网上搜到一篇spring3常见异常的文章,现转载如下:
以下异常使用的是spring是3.1.1,是我自己学习中遇到的错误笔记,有可能不是都适用,仅做参考
异常1:java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
缺少包commons-logging的jar,本人下载了一个commons-logging-1.1.1.jar,引入,问题解决,下载地址点击打开链接
异常2:java.lang.NoClassDefFoundError: org/springframework/dao/support/PersistenceExceptionTranslator
缺少包,加入org.springframework.transaction-3.1.1.RELEASE.jar即可
异常3:Offending resource: class path resource
缺少包,加入org.springframework.aop-3.1.1.RELEASE.jar即可
异常4:java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
缺少包aopalliance-alpha1.jar
下载地址http://sourceforge.net/projects/aopalliance/files/ 下完引入
异常5:java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
缺少包com.springsource.org.aopalliance-1.0.0.jar,下载地址点击打开链接下完引入
异常6: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'org.springframework.transaction.interceptor.TransactionInterceptor#0' must be of type [org.aopalliance.aop.Advice], but was actually of type [org.springframework.transaction.interceptor.TransactionInterceptor]
原因是aopalliance-alpha1.jar和com.springsource.org.aopalliance-1.0.0.jar冲突了,删除前者(这里有点不是很明白,异常4的解决包怎么就可以删除了呢,是不是异常5的解决方法也适用于异常4,有待尝试)
异常7: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的包,下载地址http://sourceforge.net/projects/cglib/files/latest/download?source=files 下完引入
异常8:java.lang.NoClassDefFoundError: javax/mail/MessagingException