SpringBoot項目啓動報錯An attempt was made to call a method that does not exist. 解決它!

報錯日誌是這樣的

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.context.annotation.AnnotationConfigUtils.processCommonDefinitionAnnotations(AnnotationConfigUtils.java:259)

The following method did not exist:

    org.springframework.beans.factory.annotation.AnnotatedBeanDefinition.setRole(I)V

The method's class, org.springframework.beans.factory.annotation.AnnotatedBeanDefinition, is available from the following locations:

    jar:file:/D:/Java/maven/gao_repository/repository/org/springframework/spring-beans/5.0.9.RELEASE/spring-beans-5.0.9.RELEASE.jar!/org/springframework/beans/factory/annotation/AnnotatedBeanDefinition.class
    jar:file:/D:/Java/maven/gao_repository/repository/org/apache/activemq/activemq-all/5.14.0/activemq-all-5.14.0.jar!/org/springframework/beans/factory/annotation/AnnotatedBeanDefinition.class

It was loaded from the following location:

    file:/D:/Java/maven/gao_repository/repository/org/springframework/spring-beans/5.0.9.RELEASE/spring-beans-5.0.9.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.beans.factory.annotation.AnnotatedBeanDefinition
說明:

試圖調用不存在的方法。嘗試從如下位置進行:
org.springframework.context.annotation.AnnotationConfigUtils.processCommonDefinitionAnnotations(AnnotationConfigUtils.java:259)

如下方法不存在:
org.springframework.beans.factory.annotation.AnnotatedBeanDefinition.setRole(I)V

方法的類org.springframework.beans.factory.annotation.AnnotatedBeanDefinition可從如下位置得到:

jar:file:/D:/Java/maven/gaou repository/repository/org/springframework/spring beans/5.0.9.RELEASE/spring-beans-5.0.9.RELEASE.jar!/org/springframework/beans/factory/annotation/AnnotatedBeanDefinition.class

jar:file:/D:/Java/maven/gaoúu repository/repository/org/apache/activemq/activemq all/5.14.0/activemq-all-5.14.0.jar!/org/springframework/beans/factory/annotation/AnnotatedBeanDefinition.class

它是從如下位置加載的:
文件:/D:/Java/maven/gaoúu repository/repository/org/springframework/spring beans/5.0.9.RELEASE/spring-beans-5.0.9.RELEASE.jar

行動:
更正應用程序的類路徑,使其包含org.springframework.beans.factory.annotation.AnnotatedBeanDefinition的單一兼容版本

解決思路

  • 我在網上找,有網友說要刪除這個jar,我信了....結果,刪完程序直接出錯了,可想而知我這裏不是這個問題。

注意: 是jar衝突的問題,由於springboot內置了activemq,只有這兩個其中一個便可java

  • 看一下你的pom依賴圖

  • 看你pom文件引入的依賴

  • 而後我嘗試將spring-boot-starter刪除

  • 再啓動,解決

相關文章
相關標籤/搜索