【问题标题】:Spring boot run error春季开机运行报错
【发布时间】:2018-08-27 18:25:49
【问题描述】:

项目 spring boot 1..5.7 发布。我正在使用 Intellij IDEA 2017.2.4 和 gradle 进行依赖管理。当我构建项目时,它构建成功,没有错误。当我使用 bootRun gradle 任务运行应用程序时,它显示以下错误。

线程“主”java.lang.IllegalArgumentException 中的异常:无法实例化接口 org.springframework.boot.SpringApplicationRunListener:org.springframework.boot.context.event.EventPublishingRunListener 在 org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:413) 在 org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:392) 在 org.springframework.boot.SpringApplication.getRunListeners(SpringApplication.java:378) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:291) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) 在 com.kifiya.lmanagement.LmanagementApplication.main(LmanagementApplication.java:13) 引起:org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.boot.context.event.EventPublishingRunListener]:构造函数抛出异常;嵌套异常是 java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object; 在 org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154) 在 org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:409) ... 6 更多 引起:java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object; 在 org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:105) 在 org.springframework.boot.context.event.EventPublishingRunListener.(EventPublishingRunListener.java:56) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在 java.lang.reflect.Constructor.newInstance(Constructor.java:423) 在 org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142) ... 7 更多

【问题讨论】:

  • 你解决了吗?

标签: spring spring-boot gradle


【解决方案1】:

看起来spring-aop 与您的其他库不匹配。尝试运行 gradle dependencies 并检查所有 Spring 依赖项是否在同一版本中。更多关于检查 Gradle User Manual 中的依赖关系。

【讨论】:

    【解决方案2】:

    正如上面提到的,这似乎是 Spring 中的依赖问题。恕我直言,最简单的方法是检查您的 POM 文件。

    在这里查看更多信息:https://docs.gradle.org/current/userguide/introduction_dependency_management.html

    【讨论】:

    • 项目中没有pom文件。这是一个 gradle spring boot 项目。
    【解决方案3】:

    老问题,但在将 Spring 应用程序转换为 Spring Boot 后,我​​遇到了同样的错误。使用 spring-boot-starter-aop 而不是直接依赖于特定版本的 spring-aop 为我解决了它,例如在build.gradle:

    plugins {
    
        id 'org.springframework.boot' version '1.5.17.RELEASE'
    }
    
    apply plugin: 'io.spring.dependency-management'
    
    dependencies {
    
        compile 'org.springframework.boot:spring-boot-starter-aop' 
    
    }
    

    而不是

    dependencies {
    
        compile 'org.springframework:spring-aop:4.2.4.RELEASE'
    }
    

    【讨论】:

      猜你喜欢
      • 2020-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多