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

 

相关文章:

  • 2022-12-23
  • 2021-05-21
  • 2021-09-17
  • 2021-09-30
  • 2021-08-10
  • 2022-12-23
  • 2021-09-19
  • 2022-03-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案