1.1 macos安装

  1. brew install wxwidgets
  2. brew install erlang
  3. brew install rabbitmq

1.2 访问地址

http://localhost:15672

用户名:guest
密码:guest

1.3 maven依赖

  1. <dependency>
  2. <groupId>org.springframework.amqp</groupId>
  3. <artifactId>spring-rabbit-test</artifactId>
  4. <scope>test</scope>
  5. </dependency>

1.3 application.yml

  1. spring:
  2. rabbitmq:
  3. username: admin
  4. password: lzf990507
  5. addresses: 127.0.0.1
  6. port: 15672
  7. mq:
  8. queue:
  9. name: "test-mq"

1.4 配置文件

  1. /**
  2. QueueConfig.java
  3. */
  4. package com.example.mq.config;
  5. import org.springframework.amqp.core.Queue;
  6. import org.springframework.beans.factory.annotation.Value;
  7. import org.springframework.context.annotation.Bean;
  8. import org.springframework.context.annotation.Configuration;
  9. @Configuration
  10. public class QueueConfig {
  11. @Value("${mq.queue.name}")
  12. private String queueName;
  13. @Bean
  14. public Queue createQueue() {
  15. return new Queue(queueName);
  16. }
  17. }