zoukankan      html  css  js  c++  java
  • 微服务:整合 Spring Boot Admin

    一、简介

      Spring Boot Admin 客户端的搭建是很简单的。通过 maven 引入 spring-boot-admin-starter-client,maven就会将必要的jar包引入到项目中,其中就包括actuator。在通过简单的配置就可以在Spring Boot Admin 服务端监控微服务应用即Spring Boot应用。

    二、实战

    1、项目结构

    2、microservice-provider -> pom.xml

    <?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>microservice-minitor</artifactId>
            <groupId>com.microservice</groupId>
            <version>1.0-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>microservice-provider</artifactId>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-starter-client</artifactId>
                <version>2.2.0</version>
            </dependency>
    
        </dependencies>
    
    </project>

    3、microservice-provider ->  application.yml

    spring:
      application:
        name: microservice-provider
      boot:
        admin:
          client:
            url: http://localhost:8888
    server:
      port: 8101
    
    management:
      endpoints:
        web:
          exposure:
            include: '*'
      endpoint:
        health:
          show-details: ALWAYS

    至此客户端配置就完成了。其实Consumer和Provider的配置类似

    三、运行测试

    1、启动 microservice-monitor-server

    2、启动microservice-provider,可以多启动几个实例。

    3、启动microservice-consumer

    打开浏览器:http://localhost:8888/wallboard

    并查看其中一个实例,看看都有啥:

    运行成功,效果完美!

  • 相关阅读:
    哈希算法(Hash Algorithm)初探
    一本计划中的WPF图书目录
    php中关于mysqli和mysql区别的一些知识点整理
    PHP Plurk Api基�教�(一)
    Wordpress 去除重复评论限制
    [share]PDO操作MySql类
    PHP处理文件(转载)
    PHP 取得某天前后N天的日期
    源码搭建LAMP服务器
    PHP ��/日期操作��
  • 原文地址:https://www.cnblogs.com/yansg/p/12581878.html
Copyright © 2011-2022 走看看