SpringBoot项目启动报错An attempt was made to call a method that does not exist. 解决它!

亦凉 2023-07-23 12:58 147阅读 0赞

报错日志是这样的

  1. ***************************
  2. APPLICATION FAILED TO START
  3. ***************************
  4. Description:
  5. An attempt was made to call a method that does not exist. The attempt was made from the following location:
  6. org.springframework.context.annotation.AnnotationConfigUtils.processCommonDefinitionAnnotations(AnnotationConfigUtils.java:259)
  7. The following method did not exist:
  8. org.springframework.beans.factory.annotation.AnnotatedBeanDefinition.setRole(I)V
  9. The method's class, org.springframework.beans.factory.annotation.AnnotatedBeanDefinition, is available from the following locations:
  10. 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
  11. 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
  12. It was loaded from the following location:
  13. file:/D:/Java/maven/gao_repository/repository/org/springframework/spring-beans/5.0.9.RELEASE/spring-beans-5.0.9.RELEASE.jar
  14. Action:
  15. Correct the classpath of your application so that it contains a single, compatible version of org.springframework.beans.factory.annotation.AnnotatedBeanDefinition
  16. 说明:
  17. 试图调用不存在的方法。尝试从以下位置进行:
  18. org.springframework.context.annotation.AnnotationConfigUtils.processCommonDefinitionAnnotations(AnnotationConfigUtils.java:259)
  19. 以下方法不存在:
  20. org.springframework.beans.factory.annotation.AnnotatedBeanDefinition.setRole(I)V
  21. 方法的类org.springframework.beans.factory.annotation.AnnotatedBeanDefinition可从以下位置获得:
  22. 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
  23. 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
  24. 它是从以下位置加载的:
  25. 文件:/D:/Java/maven/gaoúu repository/repository/org/springframework/spring beans/5.0.9.RELEASE/spring-beans-5.0.9.RELEASE.jar
  26. 行动:
  27. 更正应用程序的类路径,使其包含org.springframework.beans.factory.annotation.AnnotatedBeanDefinition的单一兼容版本

解决思路

  • 我在网上找,有网友说要删除这个jar,我信了…结果,删完程序直接出错了,可想而知我这里不是这个问题。

注意: 是jar冲突的问题,因为springboot内置了activemq,只有这两个其中一个即可

  • 看一下你的pom依赖图

format_png

  • 看你pom文件引入的依赖

format_png 1

  • 然后我尝试将spring-boot-starter删除

format_png 2

  • 再启动,解决

format_png 3

发表评论

表情:
评论列表 (有 0 条评论,147人围观)

还没有评论,来说两句吧...

相关阅读