项目spring boot 1..5.7发布。我正在使用Intellij IDEA 2017.2.4和gradle进行依赖管理。当我构建项目时,它成功构建,没有错误。当我使用bootRun gradle任务运行应用程序时,它会显示以下错误。
Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.boot.SpringApplicationRunListener : org.springframework.boot.context.event.EventPublishingRunListener at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:413) at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:392) at org.springframework.boot.SpringApplication.getRunListeners(SpringApplication.java:378) at org.springframework.boot.SpringApplication.run(SpringApplication.java:291) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) at com.kifiya.lmanagement.LmanagementApplication.main(LmanagementApplication.java:13) Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.event.EventPublishingRunListener]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object; at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154) at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:409) ... 6 more Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object; at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:105) at org.springframework.boot.context.event.EventPublishingRunListener.(EventPublishingRunListener.java:56) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142) ... 7 more
答案 0 :(得分:1)
看起来spring-aop
与其他库不匹配。尝试运行gradle dependencies
并检查所有Spring依赖项是否在同一版本中。有关检查Gradle User Manual中的依赖关系的更多信息。
答案 1 :(得分:1)
这似乎是Spring中的依赖问题,如上所述。恕我直言的最简单方法是检查你的POM文件。
点击此处了解详情:https://docs.gradle.org/current/userguide/introduction_dependency_management.html
答案 2 :(得分:0)
老问题,但是在将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'
}