在我以前的 《Spring Boot應用監控實戰》 一文中,講述瞭如何利用 Spring Boot Admin 1.5.X 版原本可視化地監控 Spring Boot 應用。說時遲,那時快,如今 Spring Boot Admin 都更新到 2.0 版本了,而且能夠對當下熱門的 Spring Boot 2.0 和 Spring Cloud Finchley.RELEASE 進行監控,所以本文就來了解並實踐一下!git
注: 本文首發於 My 公衆號 CodeSheep ,可 長按 或 掃描 下面的 當心心 來訂閱 ↓ ↓ ↓
Spring Boot Admin 2.0 變化仍是挺多的,具體參考 官網說明,這裏列幾條主要的:github
等等...web
下面就實際試驗來操做感覺一下!spring
<dependencies> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-server</artifactId> <version>2.0.1</version> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server-ui</artifactId> <version>2.0.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
@SpringBootApplication @EnableAdminServer public class SbaServer20Application { public static void main(String[] args) { SpringApplication.run(SbaServer20Application.class, args); } }
瀏覽器打開 localhost:8080
,就能夠看到小清新的頁面了編程
能夠看到這個 UI 的變化和 1.5.X 時代的差距仍是蠻大的,此時被監控的應用數目還爲0。c#
接下來咱們就來建立一個待監控的Spring Boot 2.0示例。瀏覽器
此處咱們依然建立一個 Spring Boot 2.0.3.RELEASE 的應用,而後加入到Spring Boot Admin之中進行監控服務器
<dependencies> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-client</artifactId> <version>2.0.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
server.port=8081 spring.application.name=Spring Boot Client spring.boot.admin.client.url=http://localhost:8080 management.endpoints.web.exposure.include=*
此時 Spring Boot Admin的頁面上應用上線的消息推送過來了:session
被監控應用上線以後,咱們進入 Spring Boot Admin頁面鼓搗看看app
做者更多的SpringBt實踐文章在此:
若是有興趣,也能夠抽點時間看看做者一些關於容器化、微服務化方面的文章: