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
原文地址:https://www.cnblogs.com/HeCG95/p/11784783.html
时间: 2024-11-06 15:30:43