• spring-boot admin的使用


    spring boot admin为spring boot应用提供了整合的视图,应用的详情视图提供了应用本身及运行时环境(OS和JVM)运维比较关心的数据,应用的运行时信息,log输出,metrics统计,environment和logging level实时调整,thread线程运行时状态,trace,audit和Hystrix。 同时提供了turbine扩展插件,用于整合展示整个集群的熔断器信息。 在Journal模块,可以提供整个集群所有节点的状态变化历程。

    首先是服务器端的代码如下

     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">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.tuling.cloud</groupId>
      <artifactId>spring-boot-admin-server</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>
    
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
      </properties>
    
      <dependencies>
        <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>
        <dependency> 
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
            <version>1.5.9.RELEASE</version>
        </dependency> 
      </dependencies>
    
      <!-- 添加spring-boot的maven插件 -->
      <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </project>

     启动类的代码如下

    package com.tuling.cloud.study;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.context.annotation.Configuration;
    
    import de.codecentric.boot.admin.config.EnableAdminServer;
    
    @Configuration
    @EnableAutoConfiguration
    @EnableAdminServer
    public class SpringBootAdminApplication {
    
      public static void main(String[] args) {
        SpringApplication.run(SpringBootAdminApplication.class, args);
      }
    }

    然后看配置文件

    application.yml

    server:
      port: 9999 
    spring:  
      application:  
        name: service-admin  
      mail:  
        host: smtp.163.com  
        username: aaronrao2018@163.com
        password: 2018shijiebei  
        properties:  
          mail.debug: false  
          mail.smtp.auth: true  
      boot:  
        admin:  
          notify:  
            mail:  
              to: 3376224996@qq.com  
              from: aaronrao2018@163.com  
    #          ignore-changes: UNKNOWN:UP  
          routes:  
            endpoints: env,metrics,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream 
                   

    spring-admin发送邮件,需要添加下面的依赖

     <dependency> 
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
            <version>1.5.9.RELEASE</version>
        </dependency> 

    application.yml
    server:
      port: 9999 
    spring:  
      application:  
        name: service-admin  
      mail:  
        host: smtp.163.com  
        username: aaronrao2018@163.com
        password: 2018shijiebei  
        properties:  
          mail.debug: false  
          mail.smtp.auth: true  
      boot:  
        admin:  
          notify:  
            mail:  
              to: 3376224996@qq.com  
              from: aaronrao2018@163.com  
    #          ignore-changes: UNKNOWN:UP  
          routes:  
            endpoints: env,metrics,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream 
                   

    邮件发起者:

      username: aaronrao2018@163.com
        password: 2018shijiebei  
    邮件接收方
       to: 3376224996@qq.com  
              from: aaronrao2018@163.com  

     

     一个应用存在多个实例,点击detail可以查看当前应用这个实例的详细信息,我们点击detail进去



  • 相关阅读:
    traceroute命令
    ifconfig命令
    netstat命令
    ps命令
    Vue3.0新特性
    Shadow DOM的理解
    解决ufw下pptp客户端连接问题
    Event对象
    java面试一日一题:讲下mysql中的索引
    java面试一日一题:讲下mysql中的redo log
  • 原文地址:https://www.cnblogs.com/kebibuluan/p/11462776.html
Copyright © 2020-2023  润新知