文章已获得原作者授权,原文地址: https://zhuoqianmingyue.blog.csdn.net/article/details/82785269
创建springBoot 项目并引入springBoot admin 服务端的依赖:
<dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server</artifactId> <version>2.0.2</version> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server-ui</artifactId> <version>2.0.2</version> </dependency>
在SpringBoot 启动类出声明 服务端注解 @EnableAdminServer
import de.codecentric.boot.admin.server.config.EnableAdminServer; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @EnableAdminServer public class MonitorserviceApplication {
public static void main(String[] args) { SpringApplication.run(MonitorserviceApplication.class, args); } }
配置服务端的端口: server.port=8000
2、搭建 SpringBoot amdin 客户端 创建springBoot 项目并引入客户端的依赖:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-client</artifactId> <version>2.0.2</version> </dependency>
配置application.properties swagger.enable=true server.servlet.context-path=/learn server.port=8090
spring.boot.admin.client.url=http://localhost:8000 management.endpoint.health.show-details=always management.endpoints.web.exposure.include=* logging.file=E:/IntellJ IDEA/logging/info.2018-09-23.log
分别启动服务端和客户端:
|