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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM