码迷,mamicode.com
首页 > 编程语言 > 详细

springboot 监控

时间:2018-04-30 01:02:21      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:tor   技术   artifact   如何   led   add   技术分享   检查   beans   

一、什么是spring-boot-starter-actuator(doc

springboot项目如何检查配置与运行状态呢?官方提供了一些接口可以查看springboot项目运行情况,只需要导入spring-boot-starter-actuator,项目集成:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

二、监控api

技术分享图片

/autoconfig : 查看自动配置

技术分享图片

 /beans : 查看beans

技术分享图片

为了安全起见,可以单独设置监控的端口和访问地址:

management.port=9000  # 通过9000端口访问

management.address=127.0.0.1 # 只允许本机访问

 /shotdown : 关闭

打开shutdown功能:

endpoints:
shutdown:
enabled: true #启用shutdown
sensitive: false #禁用密码验证

技术分享图片

执行完毕,启动的项目已被终止了。

安全设置,设置账号密码,只有拥有账号密码的才能shutdown

 1、引用security

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
</dependency>

2、开启安全验证

endpoints:
  shutdown:
    enabled: true       #启用shutdown
    sensitive: true     #开启shutdown的安全验证
    path: /testshutdown   #指定shutdown endpoint的路径

management:
  port: 9000        #指定管理端口
  address: 127.0.0.1   #指定管理IP
  security:
    role: SUPERUSER #角色

security:
  user:
    name: admin     #验证用户名
    password: 123   #验证密码

3、postman请求shutdown 

 技术分享图片

 

springboot 监控

标签:tor   技术   artifact   如何   led   add   技术分享   检查   beans   

原文地址:https://www.cnblogs.com/mr-yang-localhost/p/8972376.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!