server端项目依赖
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
配置文件 application.properties
server.port=8181
spring.application.name=spring-boot-admin-server
启动类
package com.xiaobu;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author xiaobu
*/
@EnableAdminServer
@SpringBootApplication
public class SpringbootAdminServerApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(SpringbootAdminServerApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
System.out.println("服务启动成功......");
}
}
启动服务端,浏览器访问http://localhost:8181,即可看到下面的效果。
Admin Client 端
项目依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Admin client 端-->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.1.0</version>
</dependency>
配置文件 application.properties
#springbootadmin 监控
spring.application.name=Admin Client
#配置 Admin Server 的地址
spring.boot.admin.client.url=http://localhost:8181
#打开客户端 Actuator 的监控。
management.endpoints.web.exposure.include=*
启动类
package com.xiaobu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootAdminClientApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootAdminClientApplication.class, args);
}
}
启动Client后,服务器会自动检测到客户端的变化,并展示应用
点击实例详情查看详细监控信息:
已知bug
java.lang.IllegalStateException: Calling [asyncError()] is not valid for a request with Async state [MUST_DISPATCH]