2.x从Spring Cloud Config Server热加载配置和1.x的版本有点区别
1.添加actuator依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
2.添加actuator配置bootstrap.yml
management: endpoints: web: base-path: /actuator exposure: include: "*"
3.设置@RefreshScope注解
@RefreshScope @RestController @Slf4j public class DcController { @Autowired DiscoveryClient discoveryClient; @Value("${test.myname}") String myname; ....
4.请求post类型 ,/actuator/refresh 即可