Spring Cloud Hoxton 版本微服务项目搭建 admin 监控客户端


前言

在上一篇文章博主已经讲解了admin 管理中心服务项目如何创建,不会的话可以前往学习,传送门:Spring Cloud Hoxton 版本微服务项目搭建 admin 监控管理中心 。

本篇用来讲解–Spring Cloud Hoxton 版本微服务项目搭建 admin 监控客户端


正题

引入 Admin-Server 2.2.1 依赖:

<!-- Admin 2.2.1 版本客户端引入依赖 --><dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-client</artifactId><version>2.2.1</version></dependency>

pom.xml 配置如下:(这里用了注册中心做客户端,注册中心传送门:Spring Cloud Hoxton 版本微服务项目搭建eureka注册中心)

<?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>com.cyj</groupId><artifactId>Family</artifactId><version>1.0-SNAPSHOT</version></parent><groupId>com.cyj</groupId><artifactId>eureka-center</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>eureka-center</name><url>https://repo.spring.io/milestone</url><description>CYJ:SpringCloud Eureka Master 注册中心</description><dependencies><!-- SpringCloud Eureka 注册中心依赖 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-server</artifactId></dependency><!-- SpringCloud Hystrix 微服务容错监控组件:断路器,依赖隔离,服务降级,服务监控 依赖 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix</artifactId></dependency><!-- 权限控制依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency><!-- Admin 2.2.1 版本客户端引入依赖 --><dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-client</artifactId><version>2.2.1</version></dependency></dependencies><!-- SpringCloud 所有子项目 版本集中管理.MS:统一所有SpringCloud依赖项目的版本 依赖 --><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><!-- SpringBoot 2.2.x 以上版本这样配置 --><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><!-- SpringBoot 项目打jar包的Maven插件 --><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins><!-- SpringBoot项目打包jar名称 --><finalName>eureka-center</finalName></build><!-- SpringCloud 官方远程仓库.MS:部分本地仓库和镜像仓库没有SpringCloud子项目依赖。 --><repositories><repository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url><snapshots><enabled>false</enabled></snapshots></repository></repositories></project>

启动项如下:

package com.cyj.admincenter;import de.codecentric.boot.admin.server.config.EnableAdminServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;/*** 启动类** @author Chenyongjia* @Description: AdminCenterApplication* @ClassName: Application.java* @Date 2019年12月30日 晚上20:29:06* @Email 867647213@qq.com*/
@Slf4j
@EnableAdminServer
@EnableEurekaClient
@EnableDiscoveryClient
@SpringBootApplication
public class AdminCenterApplication {public static void main(String[] args) {log.info("=======》启动 Admin 管理项目ing......");SpringApplication.run(AdminCenterApplication.class, args);log.info("=======》启动 Admin 管理项目成功......");}}

yml 配置文件如下:

新增配置:

eureka:instance:# 每隔5s发送一次心跳lease-renewal-interval-in-seconds: 5# 告知服务端10秒还未收到心跳的话,就将该服务移除列表lease-expiration-duration-in-seconds: 10# 健康检查路径health-check-url-path: /actuator/health# Admin 管理配置
management:endpoints:web:exposure:include: '*'endpoint:health:show-details: always

完整配置:

server:#项目端口号port: 8888tomcat:max-connections: 200max-threads: 300min-spare-threads: 0uri-encoding: UTF-8logging:pattern:console: "%d - %msg%n"#path: D:\Logback-Test\             #日志输出到指定文件夹下默认名为spring.logfile: D:\Logback-Test\wordimg.log  #日志输出到指定文件#level: debug   #指定级别level:         #指定输出某个类的日志com.cnooc.wordimg.LoggerTest2: debugspring:application:name: eureka-server# 设置查看注册中心的登录用户以及他的角色security:user:name: adminpassword: 867647213roles: ROLEALL# 注册到Admin管理中心boot:admin:client:url: http://localhost:6010# Admin 管理配置
management:endpoints:web:exposure:include: '*'endpoint:health:show-details: alwayseureka:#eureka实例定义instance:#eureka实例主机名称hostname: master#表示eureka client发送心跳给server端的频率。如果在leaseExpirationDurationInSeconds后,server端没有收到client的心跳,#则将摘除该instance。#除此之外,如果该instance实现了HealthCheckCallback,并决定让自己unavailable的话,则该instance也不会接收到流量。lease-renewal-interval-in-seconds: 5#客户端进行Eureka注册的配置client:#关闭eureka的客户端行为:注册服务registerWithEureka: false#关闭eureka的客户端行为:订阅服务fetchRegistry: falseserviceUrl:#eureka注册中心地址defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/#defaultZone: http://backup:8889/eureka/,http://slave:8890/eureka/server:# 关闭自我保护机制,防止失效的服务也被一直访问 (Spring Cloud默认该配置是 true)enable-self-preservation: false# 每隔10s扫描服务列表,该配置可以修改检查失效服务的时间,每隔10s检查失效服务,并移除列表 (Spring Cloud默认该配置是 60s)eviction-interval-timer-in-ms: 5000

启动项目:


监控节点性能


最后

  • 更多参考精彩博文请看这里:《陈永佳的博客》

  • 喜欢博主的小伙伴可以加个关注、点个赞哦,持续更新嘿嘿!

Spring Cloud Hoxton 版本微服务项目搭建 admin 监控客户端相关推荐

  1. Spring Cloud Alibaba 大型微服务项目实战

    作者介绍 程序员十三,多年一线开发经验,历任高级开发工程师.后端主程.技术部门主管等职位.同时也是开源项目的爱好者和贡献者.掘金优秀作者.CSDN 博客专家.实体图书作者.专栏作者.视频讲师. 小册介 ...

  2. 《深入理解 Spring Cloud 与微服务构建》第十七章 使用 Spring Cloud OAuth2 保护微服务系统

    <深入理解 Spring Cloud 与微服务构建>第十七章 使用 Spring Cloud OAuth2 保护微服务系统 文章目录 <深入理解 Spring Cloud 与微服务构 ...

  3. Spring Cloud(5)---基于 Spring Cloud 完整的微服务架构实战

    基于 Spring Cloud 完整的微服务架构实战 技术栈 Spring boot - 微服务的入门级微框架,用来简化 Spring 应用的初始搭建以及开发过程. Eureka - 云端服务发现,一 ...

  4. 微服务等于 Spring Cloud?了解微服务架构和框架

    点击上方"芋道源码",选择"设为星标" 管她前浪,还是后浪? 能浪的浪,才是好浪! 每天 8:55 更新文章,每天掉亿点点头发... 源码精品专栏 原创 | J ...

  5. Spring Cloud与Docker微服务架构实战 PDF版 内含目录

    Spring Cloud与Docker微服务架构实战  目录 1 微服务架构概述 1 1.1 单体应用架构存在的问题1 1.2 如何解决单体应用架构存在的问题3 1.3 什么是微服务3 1.4 微服务 ...

  6. 【福利】赠书:Spring Cloud与Docker微服务架构实战(第2版)

    本次福利送出好友周立的第二版书籍! 正在关注和使用Spring Cloud的朋友们不要错过哦! 内容提要 <Spring Cloud与Docker微服务架构实战(第2版)>基于Spring ...

  7. Spring Cloud OAuth2 JWT 微服务认证服务器得构建

    文章目录 Spring Cloud OAuth2 JWT 微服务认证服务器得构建 前言 认证服务得搭建 `AuthorizationServer` `WebSecurityConfig` `Autho ...

  8. 《Spring Cloud与Docker微服务架构实战》配套代码

    不才写了本使用Spring Cloud玩转微服务架构的书,书名是<Spring Cloud与Docker微服务架构实战> - 周立,已于2017-01-12交稿.不少朋友想先看看源码,现将 ...

  9. 【Java开发】Spring Cloud 01 :微服务前提精要

    算是新开了一个 Spring Cloud 的坑,本文来源于姚半仙的<Spring Cloud 微服务项目实战>课程,大部分文字内容基于该课程,我的工作可能就是梳理归纳和拓展,希望尽快搞懂相 ...

最新文章

  1. android datepicker使用方法,android DatePicker
  2. 让iis7.5显示php错误的详细信息~
  3. iOS开发-登录界面开发(6)Toast-Swift的使用-Swfit4.1_Xcode9.3.1
  4. 关于Android studio run 按钮灰色无法运行的总结
  5. Asp.Net Core 单元测试正确姿势
  6. 每日一题:leetcode989.数组形式的整数加法
  7. havc是什么意思_avc是什么意?eduis里h.264/a – 手机爱问
  8. 父与子python下载不了_python3-父与子的编程之旅安装pygame出现的问题
  9. MFC的坐标转换GetClientRect/GetWindowRect/ClientToScreen/GetCursorPos/ScreenToClient
  10. 通过openwrt路由器访问桥接模式下的光猫
  11. MyEclipse更换背景豆沙绿
  12. vue页面无操作30分钟退出登录
  13. 使用ping检测MTU值
  14. 《VR/AR技术与应用》笔记 002
  15. Python面试——基础面试题
  16. 使用系统打印服务器配置,打印服务器配置教程.pdf
  17. [AHK]给联想E47笔记本触摸板设定热键开关,免得误碰。
  18. vue前端项目启动报错,node-sass安装失败
  19. 牛市跟熊市是什么意思股市熊市是什么意思
  20. 高光谱成像仪IEEE标准化工作

热门文章

  1. 正则表达式验证系统登录密码必须由字母数字和特殊符号组成
  2. C/C++ 中 exit() 函数
  3. [转]黄金圣斗士处女座沙加读解
  4. AHB总线介绍及其时序图
  5. Manjaro Linux使用必应图片桌面/锁屏壁纸,每天自动更换
  6. 高频交易配对交易学习——Copulas函数理解
  7. 产品经理基本功,如何画一个满分原型?
  8. 1.14 JavaScript5:常用DOM操作
  9. android请求https(一)生成BKS
  10. Mysql数据库基本知识二:表的基础操作