springboot使用MQ
@author 李思文
@company 博思软件
@createdTime 2020/2/21
- 现在pom文件中加入依赖
<!-- MQ依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
- 配置文件中加入mq相关配置
spring:
# rabbitmq配置
rabbitmq:
# mq地址
host: 172.0.0.1
# mq端口号
port: 5672
# mq账号
username: devmq
# mq密码
password: devmq
- mq配置-消息生产
/**
* @ProjectName: mqdemo
* @ClassName: MessageProducer
* @Description: 向mq指定队列中放消息
* @Author: lisiwen
* @Date: 2020/2/21 13:28
**/
@Component
public class MessageProducer {
private final Logger log = LoggerFactory.getLogger(this.getClass()