【问题标题】:java.lang.NoClassDefFoundError for org/springframework/aop/framework/AbstractAdvisingBeanPostProcessororg/springframework/aop/framework/AbstractAdvisingBeanPostProcessor 的 java.lang.NoClassDefFoundError
【发布时间】:2014-06-29 01:03:14
【问题描述】:

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

 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

我正在运行 spring 3.1.1.RELEASE。我一直在试图解决这个问题,以前的搜索几乎没有帮助。我的堆栈跟踪在这里link

【问题讨论】:

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


【解决方案1】:

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

这是 No class def found 异常的原因。将spring-aop jar 添加到您的运行时类路径。那个罐子现在一定不见了。

【讨论】:

  • 我有 spring-aop 3.1.1.RELEASE 但是,我使用的 spring-data-jpa 版本是 1.1.2.RELEASE;这似乎依赖于 Spring 3.1.2.RELEASE。我不确定 spring-core-3.1.1.RELEASE 应该使用哪个版本的 spring-data-jpa
【解决方案2】:

我也遇到了这个问题。需要排除spring-data自带的spring-aop和spring-asm,指定你想要的spring-aop版本。我用的是gradle,这里是sn-p:

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')
}

【讨论】:

    【解决方案3】:

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

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

    【讨论】:

      【解决方案4】:

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

      【讨论】:

      • mvn dependency:tree 带冒号
      【解决方案5】:

      根据上面Jay Paulynice 的非常有用的答案,我的build.gradle 文件包含这个(Spring 版本由我们自己的其他地方的 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”很有用/必要。

      【讨论】:

        猜你喜欢
        • 2015-08-01
        • 2014-12-06
        • 2013-04-06
        • 2015-04-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-19
        相关资源
        最近更新 更多