Field rocketMQTemplate in com.xxx.demo.rocketmq.ProducerService required a bean of type 'org.apache.rocketmq.spring.core.RocketMQTemplate' that could not be found.
參考ISSUE98
# 錯誤配置
spring:
rocketmq:
name-server: xxxxx
producer:
group:xxxxxx
# 正確配置
spring:
redis:
database: 0
host: localhost
........
rocketmq:
name-server: 172.16.21.138:9876
producer:
group: short-message
注意rocketmq應該和spring同個級別,因此在application.properties中的配置應該為:
# 錯誤配置
spring.rocketmq.name-server=127.0.0.1:9876
spring.rocketmq.producer.group=producer
# 正確配置
rocketmq.name-server=127.0.0.1:9876
rocketmq.producer.group=producer
開發過程中遇到的另一個問題是RocketMQTemplate無法使用,雖然.m2/repository文件夾中包含這個包,但是引用時爆紅,解決方法如下: