为项目整合Spring Boot Acuator

  1. 了解Acuator
    Spring Boot Acuator 提供了很多控制端点。从而了解应用程序的状况。
  2. Acuator监控端点及描述
    端点描述Http方法
    autoconfig显示自动配置信息GET
    beans显示应用程序所有上下文Spring beanGET
    configprops显示所有configurationProperties配置属性列表GET
    dump显示线程活动快照GET
    evn显示应用的环境变量GET
    health显示应用的程序的健康指标,这些由healthIndicator的实现类提供GET
    info显示应用信息,可以用info*属性自定义info端点公开数据GET
    mappings显示所有的url路径GET
    metrics显示应用的度量标准信息GET
    shutdown关闭应用GET
    trace显示跟踪信息(默认是100http请求GET
  3. 为项目添加依赖
    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
     </dependency>
    测试:访问 http://127.0.0.1:8080/health
    结果:
    {"status":"UP"} ,返回的是UP表示正常
    
    
    访问http://127.0.0.1:8080/info 
    结果:{}
    证明info没有公开
    结果:{}证明info没有公开
  4. 配置application.yml
    info:  
      app:  
        name: "@project.name@"   
        description: "@project.description@"  
        version: "@project.version@"  
        spring-boot-version: "@project.parent.version@" 
    再次访问 http://localhost:8080/info
    结果:
    	
    {"app":{"name":"microservice-simple-provider-user","description":"zjmdemo","version":"0.0.1-SNAPSHOT","spring-boot-version":"1.5.9.RELEASE"}}
    访问:http://127.0.0.1:8080/autoconfig
    

    Whitelabel Error Page

    This application has no explicit mapping for /error, so you are seeing this as a fallback.

    Thu Dec 21 21:54:04 CST 2017
    There was an unexpected error (type=Unauthorized, status=401).
    Full authentication is required to access this resource.
    上面的是没有开启授权 在application.yml加上 management:   security:     enabled: false 就可以访问了http://127.0.0.1:8080/autoconfig 和其他未授权的都能访问了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值