background

I get the following error when I upgrade the version of Spring Boot from 2.6.7 to 3.0.0

description

Main class

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(MainApplication.class);
        ConfigurableApplicationContext applicationContext = application.run(args);

        DefaultMQProducer bean = applicationContext.getBean(DefaultMQProducer.class);
        System.out.println("bean: " + bean);
      }
  • spring boot version 3.0.0
Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.rocketmq.client.producer.DefaultMQProducer' available
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:340)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:331)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1148)
    at indi.yuluo.scastrambindrocketmq.MainApplication.main(MainApplication.java:23)
  • spring boot version 2.6.7
bean: ClientConfig [namesrvAddr=dev1.rocketmq.leve.com:9876;dev2.rocketmq.leve.com:9876, clientIP=172.30.32.1, instanceName=8800, clientCallbackExecutorThreads=12, pollNameServerInterval=30000, heartbeatBrokerInterval=30000, persistConsumerOffsetInterval=5000, unitMode=false, unitName=null, vipChannelEnabled=true, useTLS=false, language=JAVA]

demo

https://github.com/yuluo-yx/spring-boot-demo1

Comment From: scottfrederick

Auto-configuration of a RocketMQ org.apache.rocketmq.client.producer.DefaultMQProducer bean is provided by the rocketmq-spring project.

As noted in the migration guide, Spring Boot 3.0 requires auto-configurations to be registered differently than in previous versions of Spring Boot. It appears that rocketmq-spring only uses the Spring Boot 2.x compatible way of registering auto-configurations, and needs to be updated to support Spring Boot 3.x. You;ll need to request that from the project maintainers.

Comment From: yuluo-yx

项目org.apache.rocketmq.client.producer.DefaultMQProducer提供了RocketMQ bean 的自动配置。rocketmq-spring

迁移指南中所述,Spring Boot 3.0 要求自动配置的注册方式与之前版本的 Spring Boot 不同。似乎rocketmq-spring只使用Spring Boot 2.x 兼容的方式注册自动配置,需要更新以支持 Spring Boot 3.x。您需要向项目维护者提出请求。

thanks!