依赖
<!--SpringAMQP起步依赖-->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
yml配置文件
自行修改
spring:rabbitmq:host: 192.168.220.130 # 主机名port: 5672 # 端口virtual-host: / # 虚拟主机username: user # 用户名password: 123456 # 密码
测试
@Autowiredprivate RabbitTemplate rabbitTemplate;@Testpublic void test() {String queueName = "demo.queue";String message = "这是一条消息!";rabbitTemplate.convertAndSend(queueName, message);}