当前位置:Gxlcms > 数据库问题 > 消息总线SpringCloudBus

消息总线SpringCloudBus

时间:2021-07-01 10:21:17 帮助过:40人阅读

management: #暴露触发消息总线的地址 endpoints: web: exposure: include: bus‐refresh

 

客户端  

 引入依赖 

<dependency>
   <groupId>org.springframework.cloud</groupId> 
<artifactId>spring‐cloud‐bus</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId>
<artifactId>spring‐cloud‐stream‐binder‐rabbit</artifactId>
</dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring‐boot‐starter‐actuator</artifactId>
</dependency>

配置文件中配置rabbitmq

rabbitmq:
    host: 127.0.0.1

 

测试 

Url: http://127.0.0.1:8888/actuator/bus-refresh Method: post   自定义配置文件的读取  
@RefreshScope     //注解@RefreshScope 此注解用于刷新配置
@RestController
public class TestController {
@Value("${sms.ip}") 
private String ip; 
@RequestMapping(value = "/ip", method = RequestMethod.GET) 
public String ip() {
return ip;
}
}

 

 

 

消息总线SpringCloudBus

标签:定义   更新   tor   配置文件   method   dep   sms   nts   map   

人气教程排行