Spring Boot集成 Spring Boot Admin 監控
【前言】
程序開發完實現相應的功能只是一個部分,如何讓系統在線上運行更好創造更高的價值是另外一個部分;監控是一個生產級項目避不可少重要組成部分;最近研究一下針對SpringBoot的監控項目---Spring Boot Admin,并集成項目中,在此與大家共享;
【SpringBootAdmin】
一、SpringBootAdmin簡介
1、github地址:https://github.com/codecentric/spring-boot-admin
2、重要功能列表:
二、項目中集成SpringBootAdmin
1、搭建SpringBootAdmin服務端
(1)新建springboot項目(在此項目名定為zh-monitor)
(2)pom文件如下:
<?xml version='1.0' encoding='UTF-8'?><project xmlns='http://maven.apache.org/POM/4.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd'> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.zhanghan</groupId> <artifactId>zh-parent</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> <groupId>com.zhanghan</groupId> <artifactId>zh-monitor</artifactId> <version>1.0.0-SNAPSHOT</version> <name>zh-monitor</name> <description>zhanghan monitor for Spring Boot</description> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-server</artifactId> </dependency> </dependencies> <build> <finalName>zh-monitor</finalName> </build></project>
(3)啟動類如下(ZhMonitorApplication):
/* * Copyright (c) 2019. zhanghan_java@163.com All Rights Reserved. * 項目名稱:實戰SpringBoot * 類名稱:ZhMonitorApplication.java * 創建人:張晗 * 聯系方式:zhanghan_java@163.com * 開源地址: https://github.com/dangnianchuntian/springboot * 博客地址: https://zhanghan.blog.csdn.net */package com.zhanghan.zhmonitor;import de.codecentric.boot.admin.server.config.EnableAdminServer;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication@EnableAdminServerpublic class ZhMonitorApplication { public static void main(String[] args) { SpringApplication.run(ZhMonitorApplication.class, args); }}
(4)配置文件如下(application.properties):
server.port=8091spring.application.name=zhMonitor
2、SpringBoot項目集成SpringBootAdmin客戶端
(1)Pom中增加相關依賴
<!-- spring boot admin begin --><dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-client</artifactId></dependency><!-- spring boot admin end -->
(2)啟動配置文件中增加連接服務端地址
三、部分功能效果展示:
1、詳細指標
2、Log日志級別管理
3、JVM線程
4、Web中http展示
四、項目地址:
1、地址:https://github.com/dangnianchuntian/springboot
2、代碼版本:1.5.0-Release
【總結】
1、工欲善其事必先利其器,監控為系統保駕護航,讓系統運行的更加穩定,發揮更大的業務價值;
2、接下來會為大家共享更多關于SpringBootAdmin的特性。
到此這篇關于Spring Boot集成 Spring Boot Admin 監控的文章就介紹到這了,更多相關Spring Boot Admin 監控內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!
相關文章: