• springcloud 配置actuator


    pom.xml

    
    
    <!--Spring Boot Actuator,感应服务端变化-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    bootstrap.yml
    management:
      endpoints:
        web:
          exposure:
            include: refresh,health,info
    TestController
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.cloud.context.config.annotation.RefreshScope;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    @RequestMapping("test")
    @RefreshScope
    public class TestController {
        @Value("${name.str}")
        private String str ;
    
        @RequestMapping("hi")
        public String hi(){
            System.out.println(str);
            return  str;
        }
    }

    调用接口

      http://127.0.0.1:9092/test/hi   返回   55555

    修改config端 name.str:6666

    刷新接口

      http://127.0.0.1:9092/actuator/refresh

      返回

      [
        "config.client.version",
        "name.str"
      ]

    调用接口

      http://127.0.0.1:9092/test/hi   返回   66666

    成功!

  • 相关阅读:
    RSA解密时BadPaddingException解决方法
    CAP定理的理解
    服务降级、熔断、隔离
    javascript原型 原型链
    Redis基础数据类型及应用场景
    log4j
    个人免签支付
    Spring Security Oauth2 认证
    elementUI的栅格布局
    用 Vue+ElementUI 搭建后台管理极简模板
  • 原文地址:https://www.cnblogs.com/mytzq/p/11361895.html
Copyright © 2020-2023  润新知