多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 快速开始 在项目中开始使用spring-cloud-bus的推荐方法是使用依赖关系管理系统 - 下面的代码段可以复制并粘贴到您的构建中。需要帮忙?请参阅我们使用Maven和Gradle构建的入门指南。 ### Maven ```xml <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-bus-parent</artifactId> <version>1.3.0.M1</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bus-amqp</artifactId> </dependency> </dependencies><repositories> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/libs-milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> ``` ### Gradle ```groovy buildscript { dependencies { classpath "io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE" } } apply plugin: "io.spring.dependency-management" dependencyManagement { imports { mavenBom 'org.springframework.cloud:spring-cloud-bus:1.3.0.M1' } } dependencies { compile 'org.springframework.cloud:spring-cloud-starter-bus-amqp' }repositories { maven { url 'https://repo.spring.io/libs-milestone' } } ``` 只要Spring Cloud Bus AMQP和RabbitMQ在classpath上,任何Spring Boot应用程序将尝试连接 `localhost:5672` ( `spring.rabbitmq.addresses` 的默认值)上的RabbitMQ服务器: ```java @Configuration @EnableAutoConfiguration @RestController public class Application { @RequestMapping("/") public String home() { return "Hello World"; } public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ```