1.1 macos安装
brew install wxwidgets
brew install erlang
brew install rabbitmq
1.2 访问地址
用户名:guest
密码:guest
1.3 maven依赖
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-test</artifactId>
<scope>test</scope>
</dependency>
1.3 application.yml
spring:
rabbitmq:
username: admin
password: lzf990507
addresses: 127.0.0.1
port: 15672
mq:
queue:
name: "test-mq"
1.4 配置文件
/**
QueueConfig.java
*/
package com.example.mq.config;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class QueueConfig {
@Value("${mq.queue.name}")
private String queueName;
@Bean
public Queue createQueue() {
return new Queue(queueName);
}
}