在我以前的 《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 ,可 长按 或 扫描 下面的 当心心 来订阅 ↓ ↓ ↓github
Spring Boot Admin 2.0 变化仍是挺多的,具体参考 官网说明,这里列几条主要的:web
使用Vue.js重写了UI界面,漂亮得不像实力派spring
直接集成了基于 spring security 的认证,无需引入第三方模块编程
加入 session endpoint 的监控支持c#
等等...浏览器
下面就实际试验来操做感觉一下!bash
<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。markdown
接下来咱们就来建立一个待监控的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的页面上应用上线的消息推送过来了:
被监控应用上线以后,咱们进入 Spring Boot Admin页面鼓捣看看
做者更多的SpringBt实践文章在此:
若是有兴趣,也能够抽点时间看看做者一些关于容器化、微服务化方面的文章: