SpringBootAdmin服务端和客户端

/ SpringBootJava / 0 条评论 / 530 浏览

SpringBootAdmin是一个SpringBoot项目的监控应用

提供如下功能:

它为注册的应用程序提供以下功能。

启动

启动AdminApplication,访问http://localhost:8888

启动

详情

创建客户端admin-client

pom.xml文件添加以下内容

  <properties>
	<maven.compiler.source>1.8</maven.compiler.source>
	<maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.0.4.RELEASE</version>
  </parent>
  <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.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>
	<!-- 在管理界面中与 JMX-beans 进行交互所需要被依赖的 JAR -->
	<dependency>
	  <groupId>org.jolokia</groupId>
	  <artifactId>jolokia-core</artifactId>
	</dependency>
  </dependencies>
  <build>
	<plugins>
	  <plugin>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-maven-plugin</artifactId>
		<executions>
		  <execution>
			<goals>
			  <goal>build-info</goal>
			</goals>
		  </execution>
		</executions>
	  </plugin>
	</plugins>
  </build>

创建application.yml

server:
  port: 8890
management:
  endpoint:
	health:
	  show-details: always
  endpoints:
	web:
	  base-path: /
	  exposure:
		include: "*"
spring:
  application:
	name: admin-client
  boot:
	admin:
	  client:
		instance:
		  prefer-ip: true
		url: http://localhost:8888
logging:
  file: ./client/log.log
  level:
	root: info

创建ClientApplication.java

package org.lianglianglee.client;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @ClessName ClientApplication
 * @Desc SpringBootAdmin-Client启动类
 * @Author liangliang
 * @Date 2018/9/10 22:29
 * @Version 1.0
 */
@SpringBootApplication
public class ClientApplication {
  public static void main(String[] args){
	SpringApplication.run(ClientApplication.class,args);
  }
}

启动

访问http://localhost:8888

请输入图片描述