目录
启动项目时报错
The producer group[ ] has been created before, specify another name please.
网上方案
并且项目启动直接失败,从报错来看是group被创建了两次,网上查了一下解决方案基本都是
new DefaultMQProducer时,提供instance name,而且instance name唯一。
producer.setInstanceName(RunTimeUtil.getRocketMqUniqeInstanceName());
详细见下文
个人问题
但是项目之前是没有这个问题的,对比发现启动日志中打印了两次启动
最后发现是因为项目中的web.xml导致,springboot内置的tomcat和外置的tomcat启动了两次导致的producer group 确实被注册了两次,解决方案去掉web.xml 并且在 pom.xml中添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
解决方案
Springboot部署到tomcat中启动了两次问题 - 吾码的博客 - 博客园
其他资料