1. 程式人生 > >Spring Boot學習-快速搭建 Actuator和spring boot admin 進行監控(八)

Spring Boot學習-快速搭建 Actuator和spring boot admin 進行監控(八)

1 搭建SpringBoot admin 服務端

    建立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

package cn.lijunkui.monitorservice;

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

3 進行測試

分別啟動服務端和客戶端