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