Amqp与RabbitMQ使用
pom: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> </dependency> 配置: spring.rabbitmq.host=127.0.0.1 spring.rabbitmq.username = guest spring.rabbitmq.password =guest Main类,启动rabbitmq注释。 @EnableRabbit public class DemoApplication {} 监控类Service,必须@EnableRabbit与@RabbitListener一起使用。 才可以有其他写法,也可以指定监控配置等,官网有写法说明: https://docs.spring.io/spring-amqp/docs/2.0.2.RELEASE/api/org/springframework/amqp/rabbit/annotation/EnableRabbit.html @Service public class BookService { @RabbitListener(queues = "cw.news" ) public void receive(Book book){ System