springcloud config+bus 实现动态刷新
程序员文章站
2022-07-03 19:48:09
...
当远程主机上的配置文件变了之后前端获取到的数据并没有变 这个时候就需要动态刷新 让它改变
pom
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
在controller上开启更新 功能
@RestController
//开启更新功能
***@Reference***
public class TestController {
@Value("${email}")
private String test;
@GetMapping("/value")
public String returnFormValue() {
return test;
}
}
yml配置
spring:
rabbitmq:
host: 192.168.57.101
post: 5672
username: guest
password: guest