1. 程式人生 > >使用spring-boot-admin對spring-boot服務進行監控

使用spring-boot-admin對spring-boot服務進行監控

一 服務端 1.建立一個web專案

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>1.5.16.RELEASE</version>
   <relativePath/> <!-- lookup parent from repository -->
</parent>

2.pom.xml

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<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-server</artifactId> <version>1.5.6</version> </dependency> <dependency> <groupId>de.codecentric</groupId
>
<artifactId>spring-boot-admin-server-ui</artifactId> <version>1.5.6</version> </dependency>

3.啟動類

@SpringBootApplication
@EnableAdminServer
public class AdminServerApplication {

   public static void main(String[] args) {
      SpringApplication.run(AdminServerApplication.class, args);
   }
}

4.application.properties

server.port=8000

二 客戶端 1.pom.xml

<dependencies>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
   </dependency>

   <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>1.5.6</version>
   </dependency>
</dependencies>

2.application.properties

server.port=8001
spring.boot.admin.url=http://localhost:8000
management.security.enabled=false