码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot集成RocketMQ报错:Bad annotation definition in @ExtRocketMQTemplateConfiguration...

时间:2019-11-03 01:17:00      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:文件中   根据   auto   util   lease   anti   instant   pre   yml   

1.问题缘由

使用官方提供的rocketmq-spring-boot-starter提供的例子写ExtRocketMQTemplate时候,修改了配置文件中的nameServer配置,改成了和rocketmq.name-server一样的值:

## 配置文件
rocketmq:
  name-server: 192.168.2.182:9876;192.168.2.183:9876
...
demo:
  rocketmq:
    ...
    extNameServer: 192.168.2.182:9876;192.168.2.183:9876

## Java Code
@ExtRocketMQTemplateConfiguration(nameServer = "${demo.rocketmq.extNameServer}")
public class ExtRocketMQTemplate extends RocketMQTemplate {
}

2.问题描述

贴上了堆栈信息:

org.springframework.beans.factory.support.BeanDefinitionValidationException: Bad annotation definition in @ExtRocketMQTemplateConfiguration, nameServer property is same with global property, please use the default RocketMQTemplate!
    at org.apache.rocketmq.spring.autoconfigure.ExtProducerResetConfiguration.validate(ExtProducerResetConfiguration.java:153) ~[rocketmq-spring-boot-2.0.3.jar:2.0.3]
    at org.apache.rocketmq.spring.autoconfigure.ExtProducerResetConfiguration.registerTemplate(ExtProducerResetConfiguration.java:88) ~[rocketmq-spring-boot-2.0.3.jar:2.0.3]
    at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[na:1.8.0_144]
    at org.apache.rocketmq.spring.autoconfigure.ExtProducerResetConfiguration.afterSingletonsInstantiated(ExtProducerResetConfiguration.java:75) ~[rocketmq-spring-boot-2.0.3.jar:2.0.3]
...

3.问题解决

根据报错提示,nameServer不能设置为和上面rocketmq.name-server一样的值,改为不一样即可解此问题:

rocketmq:
  name-server: 192.168.2.182:9876;192.168.2.183:9876
...
# properties used in the application
demo:
  rocketmq:
    ...
    extNameServer: 192.168.2.182:9876

SpringBoot集成RocketMQ报错:Bad annotation definition in @ExtRocketMQTemplateConfiguration...

标签:文件中   根据   auto   util   lease   anti   instant   pre   yml   

原文地址:https://www.cnblogs.com/HeCG95/p/11784783.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!