SpringBoot集成RocketMQ报错:Bad annotation definition in @ExtRocketMQTemplateConfiguration...
Posted snower1995
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SpringBoot集成RocketMQ报错:Bad annotation definition in @ExtRocketMQTemplateConfiguration...相关的知识,希望对你有一定的参考价值。
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...的主要内容,如果未能解决你的问题,请参考以下文章
SpringBoot集成RocketMQ实现消息实时推送(待完成中。。。)