NoSuchMethodError: org.springframework.jms.config.DefaultJmsListenerContainerFactory.setAutoStartup

异常描述

SpringBoot项目依赖了ActiveMQ相关依赖启动的时候控制台抛出下面异常:


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsListenerContainerFactory' 
defined in class path resource [org/springframework/boot/autoconfigure/jms/JmsAnnotationDrivenConfiguration.class]: 
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [org.springframework.jms.config.DefaultJmsListenerContainerFactory]: Factory method 'jmsListenerContainerFactory'
threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.jms.config.DefaultJmsListenerContainerFactory.setAutoStartup(Z)V

查看DefaultJmsListenerContainerFactory 这个类发现其位与ActiveMQ的依赖下如下图所示:
在这里插入图片描述
我们查看这个类的所有方法搜寻是否有setAutoStartup的方法如下所示:在这里插入图片描述
我们并未找到这个方法。

解决问题

将ActiveMQ的Pom依赖升级如下所示:

        <!-- Integrate ActiveMQ
           升级版本解决
        java.lang.NoSuchMethodError: org.springframework.jms.config.DefaultJmsListenerContainerFactory.setAutoStartup(Z)V -->
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-all</artifactId>
            <version>5.15.8</version>
        </dependency>

再次查看类发现已经有setAutoStartup方法如下所示:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/javaee_gao/article/details/106061581
今日推荐