org / springframework / aop / framework / AbstractAdvisingBeanPostProcessor的java.lang.NoClassDefFoundError

时间:2014-05-11 17:50:12

标签: java spring spring-mvc spring-data-jpa

伙计我收到以下编译错误:

 May 11, 2014 1:30:41 PM org.apache.catalina.core.ApplicationContext log
 SEVERE: StandardWrapper.Throwable
 org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration    problem: Failed to import bean definitions from URL location [classpath*:META-  INF/spring/context.xml]
 Offending resource: ServletContext resource [/WEB-INF/spring/appServlet/servlet-  context.xml]; nested exception is  org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing   XML document from URL [jar:file:/C:/Users/Dean/Downloads/springsource/vfabric-tc-server-  developer-2.9.5.SR1/base-instance/wtpwebapps/cointraders-api/WEB-INF/lib/data-core-1.0.0-  SNAPSHOT.jar!/META-INF/spring/context.xml]; nested exception is    org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class  [org.springframework.data.jpa.repository.config.JpaRepositoryNameSpaceHandler] for namespace  [http://www.springframework.org/schema/data/jpa]: problem with handler class file or dependent  class; nested exception is java.lang.NoClassDefFoundError:  org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor

我正在运行春季3.1.1.RELEASE。我一直试图弄清楚这个问题,以前的搜索没什么帮助。我的堆栈跟踪link

5 个答案:

答案 0 :(得分:2)

看到你的堆栈跟踪后,我注意到它说Caused by: java.lang.ClassNotFoundException: org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor

这是No class def found异常的原因。将spring-aop jar添加到运行时类路径中。现在必须丢失那个罐子。

答案 1 :(得分:2)

我也遇到了这个问题。您需要排除带有spring-data的spring-aop和spring-asm,并指定所需的spring-aop版本。我使用gradle,这是一个片段:

compile group: 'org.springframework', name: 'spring-aop', version:'3.2.8.RELEASE'
compile (group: 'org.springframework.data', name: 'spring-data-jpa', version:'1.3.4.RELEASE'){
    exclude(module: 'spring-aop')
    exclude(module: 'spring-tx')
    exclude(module: 'spring-asm')
}

答案 2 :(得分:1)

AbstractAdvisingBeanPostProcessor的文档说它从版本3.2开始存在,而不是Spring 3.1。 同样从here你可以看到Spring 3.1.4中spring-aop工件中的所有类,该类似乎不存在。

我建议你升级到Spring 3.2并确保你的类路径上没有Spring 3.1依赖项

答案 3 :(得分:0)

如果您使用maven,您可以使用命令'mvn dependency tree'来检查项目所有jar依赖项,查找依赖于spring3.1.x并排除它。

答案 4 :(得分:0)

根据上面Jay Paulynice极其有用的答案,我的build.gradle文件包含此文件(春季版本由我们自己的BOM管理):-

dependencies {
  // Handle spring-aop conflict affecting AopInfrastructureBean (used by spring-security-core PermissionEvaluator).
  // Only use spring-aop from spring-security-core, and exclude any other instances of it.
  def withoutSpringAop = {
    exclude group: 'org.springframework', module: 'spring-aop'
  }
  implementation group: 'org.springframework.security', name: 'spring-security-core'
  implementation group: 'org.flywaydb', name: 'flyway-core', version: '5.1.4', withoutSpringAop
  implementation group: 'org.springframework.security', name: 'spring-security-web', withoutSpringAop
  implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', withoutSpringAop
  ...
}

这个简单的答案掩盖了很多痛苦;我发现在Intellij gradle窗口的(完全展开的)依赖项树中搜索“ aop”很有用/必要。