1.先给工程引入依赖 父工程有了子工程就不用导了
<!--AMQP依赖,包含RabbitMQ-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
2.配置yml文件 里边的东西记得改成自己的
spring:
rabbitmq:
host: 192.168.221.131
port: 5672
virtual-host: /
username: itcast
password: 123321
3.编写监听工具类
@Component
public class AMQPLitent {
//指定监听的消息队列
@RabbitListener(queues = "simple.queue")
public void lintest(String mes) {
System.out.println("我接收到了消息:" + mes);
}
}
4.启动项目的启动类 确保该队列存在且有消息 不然会报错

总结:



















