其他分享
首页 > 其他分享> > springcloud2.X通过actuator加载配置无效问题

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

 

标签:配置,boot,myname,RefreshScope,springcloud2,actuator,加载
来源: https://www.cnblogs.com/quguanwen/p/12366329.html