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

    一、简介

      Spring Boot Admin 用于监控基于 Spring Boot 的应用,它是在 Spring Boot Actuator 的基础上提供简洁的可视化 WEB UI。

      客户端应用可以通过Spring Boot Admin Client或者注册中心就可以注册到Spring Boot Admin服务端进行监控。Spring Boot Admin 是在 Spring Boot Actuator 的基础上提供简洁的可视化 WEB UI。2.X版本使用Vue.js重写了UI界面,简洁。

    二、服务端搭建实战

    1、项目结构

    2、父pom.xml

     定义Spring Boot 及 Spring Cloud 版本

    <?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">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.microservice</groupId>
        <artifactId>microservice-minitor</artifactId>
        <packaging>pom</packaging>
        <version>1.0-SNAPSHOT</version>
        <modules>
            <module>microservice-monitor-server</module>
        </modules>
    
        <properties>
            <java.version>1.8</java.version>
            <spring-boot.version>2.2.4.RELEASE</spring-boot.version>
            <spring-cloud.version>Hoxton.SR1</spring-cloud.version>
        </properties>
    
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-parent</artifactId>
                    <version>${spring-boot.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
    
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>${spring-cloud.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    
    </project>

    3、microservice-monitor-server -> 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-monitor-server</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-server</artifactId>
                <version>2.2.0</version>
            </dependency>
        </dependencies>
    </project>

    4、microservice-monitor-server ->  MinitorServerApplication

    package com.microservice.minitor;
    
    import de.codecentric.boot.admin.server.config.EnableAdminServer;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    @EnableAdminServer
    public class MinitorServerApplication {
        public static void main(String[] args) {
            SpringApplication.run(MinitorServerApplication.class, args);
        }
    }

    5、microservice-monitor-server ->  application.yml

    server:
      port: 8888
    spring:
      application:
        name: SpringBootAdmin
      boot:
        admin:
          ui:
            title: SpringBootAdmin-Server

    三、运行测试

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

     出现如下界面,就表示Spring Boot Admin 服务端搭建成功!

  • 相关阅读:
    个人技术总结--MUI框架的h5+前端开发
    无废话MVC入门教程四[视图中的Layout使用]
    VMware Workstation 12 安装大于4GB的GHOST 64位win7系统
    转:VMware Workstation 14虚拟机安装Win7系统图文教程(详细)
    VMware Workstation Pro v15.5.6 官方版+激活密钥
    Idea 全局替换指定字符
    Springboot 使用PageHelper分页插件实现分页
    使用redis做分布式锁
    浅说缓存穿透、缓存击穿、缓存雪崩
    linux下安装mysql5.6
  • 原文地址:https://www.cnblogs.com/yansg/p/12574949.html
Copyright © 2011-2022 走看看