java.lang.NoSuchMethodError

    xiaoxiao2021-12-14  24

    项目突然启动报错了

    WARN | Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation(Ljava/lang/reflect/AnnotatedElement;Ljava/lang/Class;)Z ERROR | Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation(Ljava/lang/reflect/AnnotatedElement;Ljava/lang/Class;)Z

    搜索到StackOverflow中解释是包冲突,又根据报错信息来看是spring init方法报错,bean创建失败,找不到AnnotatedElementUtils.hasAnnotation方法,所以判定为spring包冲突。于是更换了spring几个版本,都问题依旧,最后发现新引入的activemq有问题

    通过maven引入的activemq

    <!-- https://mvnrepository.com/artifact/org.apache.activemq/activemq-all --> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-all</artifactId> <version>${activemq.version}</version> </dependency>

    发现这个包下引入了整个spring包,引起了包冲突。

    解决方法:不用maven引入,手动引入activemq的一个jar包即可。

    转载请注明原文地址: https://ju.6miu.com/read-964274.html

    最新回复(0)