spring boot 开发之监控程序运行状态

spring boot 开发之监控程序运行状态,第1张

spring boot 开发之监控程序运行状态 Actuator
	Spring Boot 给我们提供了 Actuator 这个包,这个包的关键特性是在应用程序中提供众多的web端点,
通过他们了解应用程序运行时内部的状况, 在 Maven 里面加入依赖, 程序启动起来以后我们就可以通过访问 
**/env  **/beans ...	等等路径来了解程序运行过程中的信息

actuator : 我可能和计算机关系比较好, 不信你看看你能看懂吗? -_- <不过用起来真的方便>


为了对actuator提供的程序内部的信息可视化并且进行很方便的管理, 需要用到spring 的另外一个包
(spring-boot-admin)

Admin server 端
使用 admin 这个包我们可以构造一个web程序(server)

  构造起来很简单只需要建立 spring boot 工程,  在maven中加入
        
            de.codecentric
            spring-boot-admin-starter-server
            2.3.1
        
在入口类上面加上下面的注解
	@EnableAdminServer
打包发布就行了 我的spring boot 版本是  2.4.0, 如果报错了那大概率就是 admin 的版本不对
client 端
	我们只需要对需要监控的程序进行如下配置
  1. pom.xml
        
            de.codecentric
            spring-boot-admin-starter-client
            2.3.1
        
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        
  1. application.properties
server.port = 9090
management.endpoints.web.exposure.include=*
spring.boot.admin.client.url=http://localhost:8080
spring.boot.admin.client.url=http://localhost:8080 :这个配置指定了服务器的地址
management.endpoints.web.exposure.include=* :这个配置指定了actuator开放的信息
server.port = 9090 : 指定本程序使用的端口号


使用 actuator的时候记得开启 security模块 ....

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5686511.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存