springcloud2.X通过actuator加载配置无效问题

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 即可

 

上一篇:actuator的使用


下一篇:SpringBoot---监控与管理actuator