SpringBoot_Actuator_AdminUI

AdminUI的原理:

服务端:

1、pom.xml

<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<!-- Spring Boot Actuator对外暴露应用的监控信息,Jolokia提供使用HTTP接口获取JSON格式 的数据 -->
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- 将原来本身的 1.1.1版本强制改为1.1版本 -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>

</dependencies>

2、启动App类

@ConfigurationProperties
@EnableAutoConfiguration
@EnableAdminServer

3、application.yml

spring:
  application:
    name: spring-boot-admin-server

客户端:

1、application.yml

spring: ##配置client 注册到admin ui 平台
  boot:
    admin:
      client:
        url: http://localhost:8080
server:
  port: 8081 ### 端口号
### 开放所有的监控接口监控权限
management:
  endpoints:
    web:
      exposure:
        include: "*"

2、pom.xml

<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

注意:先启动服务端,在启动客户端,以为客户端要在配置文件里指定服务端,必须是服务端存在。

原文地址:https://www.cnblogs.com/wenwenzuiniucha/p/14508635.html