五、微服务之监控中心(客户端)

五、微服务之监控中心(客户端)

主要依赖
<?xml version="1.0" encoding="UTF-8"?>
<project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath/>
        <!-- lookup parent from repository -->
    </parent>
    <groupId>com.fatcat</groupId>
    <artifactId>fc-search</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <name>fc-search</name>
    <description>客户端</description>
    <properties>
        <java.version>1.8</java.version>
        <spring-boot-admin.version>2.2.1</spring-boot-admin.version>
        <spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
    </properties>
    <dependencies>
        <!-- WEB-MVC 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- 全局更换服务器为 jetty,更轻量 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
        <!-- EUREKA 注册中心 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <!-- ADMIN 监控中心 -->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-dependencies</artifactId>
                <version>${spring-boot-admin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>
配置文件
# 服务端口 
server.port=9901
# 服务名称 
spring.application.name=fc-search 
# 配置工程访问路径前缀,和路由匹配规则保持一致 
server.servlet.context-path=/fc-search 
# eureka 注册地址 
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/ 
# 自身的主机地址 
eureka.instance.hostname=localhost 
# 心跳周期,单位秒 
eureka.instance.lease-renewal-interval-in-seconds=10 
# 过期时间,单位秒,即60s没有心跳就从注册中心剔除 
eureka.instance.lease-expiration-duration-in-seconds=30 
# 健康监控,暴露自身健康相关全部接口 
management.endpoints.web.exposure.include=* 
# 健康信息显示 
management.endpoint.health.show-details=always 
# path相对路径;url绝对路径 
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator 
#eureka.instance.home-page-url-path=${server.servlet.context-path}/actuator/ 
#eureka.instance.status-page-url-path=${server.servlet.context-path}/actuator/info 
#eureka.instance.health-check-url-path=${server.servlet.context-path}/actuator/health