日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java 分布式服务_java分布式微服务云架构- SrpingBoot Admin

發布時間:2025/3/12 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 分布式服务_java分布式微服务云架构- SrpingBoot Admin 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、SrpingBoot Admin 介紹

Spring Boot Admin 是一個開源社區項目,用于管理和監控 SpringBoot 應用程序,展示Spring Boot Admin Client 的 Actuator 端點上的一些監控信息。

了解springcloud架構可以加求求:三五三六二四七二五九

它為應用程序提供以下功能:

顯示應用健康狀況

關注并下載日志文件

查看jvm系統和環境屬性

查看Spring Boot配置屬性

支持Spring Cloud的postable / env-和/ refresh-endpoint

輕松的日志級管理

二、SrpingCloud Kubernetes 介紹

Spring Cloud Kubernetes 提供 Kubernetes 環境下服務發現的 Spring Cloud 通用接口實現。主要目的是促進在 Kubernetes 中運行的 Spring Cloud 和 Spring Boot 應用程序的集成。

這里我們主要用 SpringCloud Kubernetes 來為 SpringBoot Admin 提供 Kubernetes 環境下的服務發現。

三、創建 SpringBoot Admin 應用

創建 SpringBoot Admin 應用,且引入 SpringCloud Kubernetes 作為服務發現。

Maven 引入相關依賴

在 Maven 中引入 “spring-boot-admin-starter-server” 與 “spring-cloud-kubernetes-discovery” 依賴。

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0?http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

org.springframework.boot

spring-boot-starter-parent

2.1.6.RELEASE

club.mydlq

springboot-admin-k8s

0.0.2

springboot-admin-k8s

demo

1.8

org.springframework.boot

spring-boot-starter-web

de.codecentric

spring-boot-admin-starter-server

2.1.5

org.springframework.cloud

spring-cloud-kubernetes-discovery

1.0.2.RELEASE

org.springframework.boot

spring-boot-maven-plugin

配置 application 文件

加上兩個參數:

spring.cloud.kubernetes.discovery.primaryPortName:

spring.cloud.kubernetes.discovery.serviceLabels:

server:

port:?8080

management:

server:

port:?8081??????????????????????????#---指定監控數據端口為8081,避免和?server.port?一致產生風險

endpoints:

web:

exposure:

include:?"*"

spring:

application:

name:?springboot-admin-k8s

cloud:

kubernetes:

discovery:

primaryPortName:?management?????#---按設要監控?Service?的端口名稱

serviceLabels:

admin:?enabled????????????????#---設置要監控?Service?的?Label?標簽

啟動類

需要加上四個注解:

@SpringBootApplication:開啟 SpringBoot 相關注解,會自動配置相關信息。

@EnableDiscoveryClient:開啟 Spring服務發現機制。

@EnableAdminServer:開啟 SpringBoot Admin。

@EnableScheduling:開啟定時任務,不加此注解服務發現不會執行定時刷新。

import?de.codecentric.boot.admin.server.config.EnableAdminServer;

import?org.springframework.boot.SpringApplication;

import?org.springframework.boot.autoconfigure.SpringBootApplication;

import?org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import?org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication

@EnableDiscoveryClient

@EnableAdminServer

@EnableScheduling

public?class?Application?{

public?static?void?main(String[]?args)?{

SpringApplication.run(Application.class,?args);

}

}

總結

以上是生活随笔為你收集整理的java 分布式服务_java分布式微服务云架构- SrpingBoot Admin的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。