国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Spring Cloud Gateway集成Sentinel 1.8.6及Sentinel Dashboard

這篇具有很好參考價值的文章主要介紹了Spring Cloud Gateway集成Sentinel 1.8.6及Sentinel Dashboard。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

一、安裝sentinel

1.下載地址:sentinel v1.8.6

2.啟動sentinel dashboard,執(zhí)行以下命令:

java -Dcsp.sentinel.log.dir=D:\xxx\sentinel\logs -Dserver.port=9217 -Dcsp.sentinel.dashboard.server=localhost:9217 -Dcsp.sentinel.heartbeat.client.ip=localhost -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=sentinel -Dsentinel.dashboard.auth.password=sentinel -jar sentinel-dashboard-1.8.6.jar

參數(shù)解釋:

-Dcsp.sentinel.log.dir:日志保存路徑,默認(rèn):${user.home}/logs/csp/

-Dserver.port=9217:控制臺服務(wù)端口,默認(rèn):8080

-Dcsp.sentinel.dashboard.server=localhost:9217:控制臺訪問端口,默認(rèn):8080

-Dcsp.sentinel.heartbeat.client.ip=localhost:客戶端心跳ip,多網(wǎng)卡需要指定這個ip,否則啟動后報(bào)錯,可忽略

-Dproject.name=sentinel-dashboard:控制臺顯示名稱

-Dsentinel.dashboard.auth.username=sentinel:控制臺登錄賬號,默認(rèn):sentinel

-Dsentinel.dashboard.auth.password=sentinel:控制臺登錄密碼,默認(rèn):sentinel

-jar sentinel-dashboard-1.8.6.jar:運(yùn)行sentinel1.8.6 jar包

3.啟動成功界面

Spring Cloud Gateway集成Sentinel 1.8.6及Sentinel Dashboard

4.登錄控制臺,登錄賬號和密碼默認(rèn)為sentinel,啟動命令可自定義登錄賬號和密碼。

Spring Cloud Gateway集成Sentinel 1.8.6及Sentinel Dashboard

二、Gateway網(wǎng)關(guān)pom.xml引入sentinel組件

<!-- spring cloud gateway 核心 -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
? ? <version>3.1.4</version>
</dependency>

<!-- spring cloud gateway sentinel 適配器-->
<dependency>
    <groupId>com.alibaba.csp</groupId>
    <artifactId>sentinel-spring-cloud-gateway-adapter</artifactId>
? ? <version>1.8.6</version>
</dependency>

<!-- spring cloud gateway sentinel連接控制臺,發(fā)現(xiàn)服務(wù) -->
<dependency>
    <groupId>com.alibaba.csp</groupId>
    <artifactId>sentinel-transport-simple-http</artifactId>
? ? <version>1.8.6</version>
</dependency>

三、注入對應(yīng)的 SentinelGatewayFilter 實(shí)例以及 SentinelGatewayBlockExceptionHandler即可,參考官方文檔:https://sentinelguard.io/zh-cn/docs/api-gateway-flow-control.html。

@Configuration
public class GatewayConfiguration {

    private final List<ViewResolver> viewResolvers;
    private final ServerCodecConfigurer serverCodecConfigurer;

    public GatewayConfiguration(ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                ServerCodecConfigurer serverCodecConfigurer) {
        this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
        this.serverCodecConfigurer = serverCodecConfigurer;
    }

    @Bean
    @Order(Ordered.HIGHEST_PRECEDENCE)
    public SentinelGatewayBlockExceptionHandler sentinelGatewayBlockExceptionHandler() {
        // Register the block exception handler for Spring Cloud Gateway.
        return new SentinelGatewayBlockExceptionHandler(viewResolvers, serverCodecConfigurer);
    }

    @Bean
    @Order(-1)
    public GlobalFilter sentinelGatewayFilter() {
        return new SentinelGatewayFilter();
    }

    @PostConstruct
    public void doInit() {
        initCustomizedApis();
    }

    private void initCustomizedApis() {
    ? ? Set<ApiDefinition> definitions = new HashSet<>();
    ? ? ApiDefinition api1 = new ApiDefinition("some_customized_api")
        ? ? .setPredicateItems(new HashSet<ApiPredicateItem>() {{
            ? ? add(new ApiPathPredicateItem().setPattern("/animal/**")
                ? ? .setMatchStrategy(SentinelGatewayConstants.PARAM_MATCH_STRATEGY_PREFIX));
        ? ? }});
    ? ? ApiDefinition api2 = new ApiDefinition("another_customized_api")
        ? ? .setPredicateItems(new HashSet<ApiPredicateItem>() {{
            ? ? add(new ApiPathPredicateItem().setPattern("/system/**"));
        ? ? }});
    ? ? definitions.add(api1);
    ? ? definitions.add(api2);
    ? ? GatewayApiDefinitionManager.loadApiDefinitions(definitions);
? ? }

private void initGatewayRules() {
        Set<GatewayFlowRule> rules = new HashSet<>();
        rules.add(new GatewayFlowRule("system-route")
                .setCount(1) // 限流閾值
                .setIntervalSec(1)); // 統(tǒng)計(jì)時間窗口,單位是秒,默認(rèn)是 1 秒

        rules.add(new GatewayFlowRule("animal-route")
                .setCount(1) // 限流閾值
                .setIntervalSec(1)); // 統(tǒng)計(jì)時間窗口,單位是秒,默認(rèn)是 1 秒
        GatewayRuleManager.loadRules(rules);
    }
}

四、application.yaml配置路由

server:
  port: 9211
spring:
  application:
    name: spring-cloud-gateway
  cloud:
    gateway:
      routes:
        # Add your routes here.
        - id: system_route
          uri: lb://system
          predicates:
            - Path=/system/**
        - id: animal_route
          uri: lb://animal
          predicates:
            - Path=/animal/**

五、啟動網(wǎng)關(guān)Gateway、服務(wù),觸發(fā)限流

Spring Cloud Gateway集成Sentinel 1.8.6及Sentinel Dashboard

正常訪問

Spring Cloud Gateway集成Sentinel 1.8.6及Sentinel Dashboard

觸發(fā)限流

六、嗯哼?sentinel dashboard沒有顯示嘛,怎么回事?

Spring Cloud Gateway集成Sentinel 1.8.6及Sentinel Dashboard

按官方文檔說明,啟動配置VM參數(shù)增加:

# 注:通過 Spring Cloud Alibaba Sentinel 自動接入的 API Gateway 整合則無需此參數(shù)

-Dcsp.sentinel.app.type=1

Spring Cloud Gateway集成Sentinel 1.8.6及Sentinel Dashboard

但是?。。『孟褚膊恍校。?/span>還必須增加一個參數(shù),指向控制臺地址:

-Dcsp.sentinel.dashboard.server=localhost:9001

注意:對網(wǎng)關(guān)發(fā)起請求后,需要等待大概10秒左右,才會在sentinel dashboard看到網(wǎng)關(guān)流控控制面板。

七、小小完善

1.第六節(jié)說到,需要增加啟動配置,這里有4種解決方案。

方案一,啟動類Application增加以下參數(shù):

System.setProperty(SentinelConfig.APP_TYPE_PROP_KEY, "1");

System.setProperty("csp.sentinel.dashboard.server","localhost:9001");

System.setProperty(SentinelConfig.PROJECT_NAME_PROP_KEY,"gateway-dashboard");

方案二,啟動配置VM增加如下參數(shù):

-Dcsp.sentinel.app.type=1 -Dcsp.sentinel.dashboard.server=localhost:9001 -Dproject.name=gateway-dashboard

方案三,新增sentinel.properties配置文件,詳情參閱com.alibaba.csp.sentinel.config.SentinelConfigLoader加載配置邏輯,配置內(nèi)容如下:

project.name=gateway-dashboard # 控制臺顯示名稱

csp.sentinel.app.type=1 # 指定類型為gateway網(wǎng)關(guān)類型

csp.sentinel.dashboard.server=localhost:9211 # 指定sentinel dashboard控制臺地址

方案四,application.yaml增加自定義配置參數(shù),再參照方案一

1.自定義限流全局異常

新增異?;卣{(diào):

package com.akim.cloud.gateway.common.sentinel.handler;

import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.reactive.function.server.ServerResponse;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebExceptionHandler;
import reactor.core.publisher.Mono;

import java.nio.charset.StandardCharsets;

public class SentinelFallbackHandler implements WebExceptionHandler {
    private Mono<Void> writeResponse(ServerResponse response, ServerWebExchange exchange) {
        ServerHttpResponse serverHttpResponse = exchange.getResponse();
        serverHttpResponse.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
        byte[] datas = "{'code':429, 'msg':'系統(tǒng)繁忙,請稍后再試!'}".getBytes(StandardCharsets.UTF_8);
        DataBuffer buffer = serverHttpResponse.bufferFactory().wrap(datas);
        return serverHttpResponse.writeWith(Mono.just(buffer));
    }

    @Override
    public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
        if (exchange.getResponse().isCommitted()) {
            return Mono.error(ex);
        }
        if (!BlockException.isBlockException(ex)) {
            return Mono.error(ex);
        }
        return handleBlockedRequest(exchange, ex).flatMap(response -> writeResponse(response, exchange));
    }

    private Mono<ServerResponse> handleBlockedRequest(ServerWebExchange exchange, Throwable throwable) {
        return GatewayCallbackManager.getBlockHandler().handleRequest(exchange, throwable);
    }
}

2.改造GatewayConfiguration

可以看出上面配置api限流和服務(wù)分組時,很不友好,直接讀取application.yaml gateway配置的routes。

新增application.yaml自定義配置:

akim:
  # gateway網(wǎng)關(guān)限流
  sentinel:
    enabled: true # 是否開啟網(wǎng)關(guān)限流,默認(rèn)true
    count: 10 # 限流閾值,Double類型
    intervalSec: 1 # 統(tǒng)計(jì)時間窗口,單位:秒,Long類型,默認(rèn)1秒

新增配置文件對象類SentinelProperties.java:

package com.akim.cloud.gateway.common.sentinel.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.validation.constraints.NotNull;

@Data
@ConfigurationProperties("akim.sentinel")
public class SentinelProperties {
    @NotNull(message = "限流閾值")
    private Double count;

    @NotNull(message = "統(tǒng)計(jì)時間窗口,單位:秒")
    private Long intervalSec;
}

b.注入全局異常攔截

c.直接上代碼

package com.akim.cloud.gateway.common.sentinel.handler;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.akim.cloud.gateway.common.sentinel.config.SentinelProperties;
import com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPathPredicateItem;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPredicateItem;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.GatewayApiDefinitionManager;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
import com.alibaba.csp.sentinel.adapter.gateway.sc.SentinelGatewayFilter;
import com.alibaba.csp.sentinel.adapter.gateway.sc.exception.SentinelGatewayBlockExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.cloud.gateway.handler.predicate.PredicateDefinition;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.cloud.gateway.route.RouteDefinitionLocator;
import org.springframework.cloud.gateway.support.NameUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.web.reactive.result.view.ViewResolver;

import javax.annotation.PostConstruct;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@EnableConfigurationProperties(SentinelProperties.class)
@ConditionalOnProperty(prefix = "akim.sentinel", name = "enabled", matchIfMissing = true) // 如果配置文件屬性值為false,則不注入
@Configuration
@Slf4j
public class GatewayConfiguration {
    private final List<ViewResolver> viewResolvers;
    private final ServerCodecConfigurer serverCodecConfigurer;
    protected final RouteDefinitionLocator routeDefinitionLocator;
    private final SentinelProperties sentinelProperties;

    public SentinelBlockHandler(ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                ServerCodecConfigurer serverCodecConfigurer,
                                RouteDefinitionLocator routeDefinitionLocator, SentinelProperties sentinelProperties) {
        this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
        this.serverCodecConfigurer = serverCodecConfigurer;
        this.routeDefinitionLocator = routeDefinitionLocator;
        this.sentinelProperties = sentinelProperties;
    }

    @Bean
    @Order(Ordered.HIGHEST_PRECEDENCE)
    public SentinelFallbackHandler sentinelGatewayExceptionHandler() {
        return new SentinelFallbackHandler();
    }

    @Bean
    @Order(Ordered.HIGHEST_PRECEDENCE)
    public SentinelGatewayBlockExceptionHandler sentinelGatewayBlockExceptionHandler() {
        // Register the block exception handler for Spring Cloud Gateway.
        return new SentinelGatewayBlockExceptionHandler(viewResolvers, serverCodecConfigurer);
    }

    @Bean
    @Order(-1)
    public GlobalFilter sentinelGatewayFilter() {
        return new SentinelGatewayFilter();
    }

    @PostConstruct
    public void doInit() {
        // 限流api
        initCustomizedApis();
        // 服務(wù)分組流控
        initGatewayRules();
    }

    private void initCustomizedApis() {
        Set<ApiDefinition> definitions = new HashSet<>();
        List<RouteDefinition> routeDefinitions = routeDefinitionLocator.getRouteDefinitions().collectList().block();
        routeDefinitions.stream().forEach(route -> {
            PredicateDefinition pathDefinition = CollUtil.findOne(route.getPredicates(),
                    predicateDefinition -> "Path".equals(predicateDefinition.getName()));
            if (pathDefinition == null) {
                log.info("[sentinel][Route({}) 沒有 Path 條件,忽略接口限流]", route.getId());
                return;
            }
            String path = pathDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0");
            if (StrUtil.isEmpty(path)) {
                log.info("[sentinel][Route({}) Path 的值為空,忽略接口限流]", route.getId());
                return;
            }
            definitions.add(new ApiDefinition(route.getId() + "-api")
                    .setPredicateItems(new HashSet<ApiPredicateItem>() {
                        {
                            // 匹配 Path 前綴以及其子路徑的所有請求
                            add(new ApiPathPredicateItem().setPattern(path)
                                    .setMatchStrategy(SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX)); // 匹配前綴,不設(shè)置則認(rèn)為完全匹配
                        }
                    }));
        });
        GatewayApiDefinitionManager.loadApiDefinitions(definitions);
    }

    /**
     * 網(wǎng)關(guān)限流規(guī)則
     * GatewayFlowRule參數(shù):
     * resource: 資源名稱,可以是網(wǎng)關(guān)中的route名稱或者用戶自定義的API分組名稱。
     * resourceMode: 資源模型,限流規(guī)則則是針對API Gateway的 route(RESOURCE_MODE_ROUTE_ID)還是用戶在 Sentinel 中定義的API分組(RESOURCE_MODE_CUSTOM_API_NAME),默認(rèn)route。
     * grade:限流指標(biāo)維度,同限流規(guī)則的 grade 字段。
     * count:限流閾值。
     * intervalSec: 統(tǒng)計(jì)時間窗口,單位是秒, 默認(rèn)是1秒。
     * controlBehavior: 流量整形的控制效果,同限流規(guī)則的 controlBehavior字段,目前支持快速失敗和勻速排隊(duì)兩種模式,默認(rèn)快速失敗。
     * burst: 應(yīng)對突發(fā)請求時額外允許的請求數(shù)目。
     * maxQueueingTimeoutMs:勻速排隊(duì)模式下的最長排隊(duì)時間,單位是毫秒,僅在勻速排隊(duì)模式下生效。
     * paramItem: 參數(shù)限流配置。若不提供,則代表針對參數(shù)進(jìn)行限流,該網(wǎng)關(guān)規(guī)則將會被轉(zhuǎn)換成普通流控規(guī)則;否則會轉(zhuǎn)換熱點(diǎn)規(guī)則。其中的字段如下:
     * parseStrategy: 從請求中提取參數(shù)的策略,目前支持提取來源IP(PARAM_PARSE_STRATEGY_CLIENT_IP)、Host(PARAM_PARSE_STRATEGY_HOST)、任意Header(PARAM_PARSE_STRATEGY_HEADER)和任意URL 參數(shù)(PARAM_PARSE_STRATEGY_URL_PARAM)四種模式。
     * fieldName:若提取策略選擇Header模式或者URL參數(shù)模式,則需要指定對應(yīng)的Header名稱或URL參數(shù)名稱。
     * pattern和matchStrategy: 為后續(xù)參數(shù)匹配特性預(yù)留,目前末實(shí)現(xiàn)。
     */
    private void initGatewayRules() {
        Set<GatewayFlowRule> rules = new HashSet<>();
        List<RouteDefinition> definitions = routeDefinitionLocator.getRouteDefinitions().collectList().block();
        definitions.stream().forEach(route -> {
            if (StrUtil.isEmpty(route.getId())) {
                log.info("[sentinel][Route 沒有 Id 條件,忽略接口限流]");
                return;
            }
            rules.add(new GatewayFlowRule(route.getId())
                    .setCount(sentinelProperties.getCount()) // 限流閾值
                    .setIntervalSec(sentinelProperties.getIntervalSec())); // 統(tǒng)計(jì)時間窗口,單位是秒,默認(rèn)是 1 秒
        });
        // 加載網(wǎng)關(guān)限流規(guī)則
        GatewayRuleManager.loadRules(rules);
    }
}

搞定!文章來源地址http://www.zghlxwxcb.cn/news/detail-505753.html

到了這里,關(guān)于Spring Cloud Gateway集成Sentinel 1.8.6及Sentinel Dashboard的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 【SpringCloud】11、Spring Cloud Gateway使用Sentinel實(shí)現(xiàn)服務(wù)限流

    1、關(guān)于 Sentinel Sentinel 是阿里巴巴開源的一個流量防衛(wèi)防護(hù)組件,可以為微服務(wù)架構(gòu)提供強(qiáng)大的流量防衛(wèi)能力,包括流量控制、熔斷降級等功能。Spring Cloud Gateway 與 Sentinel 結(jié)合,可以實(shí)現(xiàn)強(qiáng)大的限流功能。 Sentinel 具有以下特性: 豐富的應(yīng)用場景:Sentinel 承接了阿里巴巴近

    2024年02月01日
    瀏覽(23)
  • 微服務(wù)集成spring cloud sentinel

    微服務(wù)集成spring cloud sentinel

    目錄 1. sentinel使用場景 2.? sentinel組成 3. sentinel dashboard搭建 ?4. sentinel客戶端詳細(xì)使用 4.1 引入依賴 4.2 application.properties增加dashboard注冊地址 4.3 手動增加限流配置類 4.4 rest接口及service類 4.5 通過dashboard動態(tài)配置限流規(guī)則 限流、熔斷、監(jiān)控、動態(tài)規(guī)則配置 由兩部分組成, 第一

    2024年02月11日
    瀏覽(24)
  • 【合集】Spring Cloud 組件——架構(gòu)進(jìn)化史話 & Eureka,Nacos,OpenFeign,Ribbon,Sentinel,Gateway ,Seata+事務(wù). . .

    【合集】Spring Cloud 組件——架構(gòu)進(jìn)化史話 & Eureka,Nacos,OpenFeign,Ribbon,Sentinel,Gateway ,Seata+事務(wù). . .

    Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智能路由,微代理,控制總線,一次性令牌,全局鎖,領(lǐng)導(dǎo)選舉,分布式會話,集群狀態(tài))。 注意: 首先,盡管Spring Cloud帶有“Cloud”這個單詞,但它并不是云計(jì)算解

    2024年02月08日
    瀏覽(23)
  • Spring Cloud Gateway集成Nacos實(shí)現(xiàn)負(fù)載均衡

    Spring Cloud Gateway集成Nacos實(shí)現(xiàn)負(fù)載均衡

    ??Nacas可以用于實(shí)現(xiàn)Spring Cloud Gateway中網(wǎng)關(guān)動態(tài)路由功能,也可以基于Nacos來實(shí)現(xiàn)對后端服務(wù)的負(fù)載均衡,前者利用Nacos配置中心功能,后者利用Nacos服務(wù)注冊功能。 接下來我們來看下Gateway集成Nacos實(shí)現(xiàn)負(fù)載均衡的架構(gòu)圖 一. 環(huán)境準(zhǔn)備 1. 版本環(huán)境 Jdk: java.version1.8/java.version Spr

    2024年02月10日
    瀏覽(98)
  • 【合集】Spring Cloud 組件——架構(gòu)進(jìn)化史話 & Eureka,Nacos,Apollo,OpenFeign,Ribbon,Sentinel,Gateway ,Seata+事務(wù). . .

    【合集】Spring Cloud 組件——架構(gòu)進(jìn)化史話 & Eureka,Nacos,Apollo,OpenFeign,Ribbon,Sentinel,Gateway ,Seata+事務(wù). . .

    Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智能路由,微代理,控制總線,一次性令牌,全局鎖,領(lǐng)導(dǎo)選舉,分布式會話,集群狀態(tài))。 注意: 首先,盡管Spring Cloud帶有“Cloud”這個單詞,但它并不是云計(jì)算解

    2024年02月03日
    瀏覽(640)
  • Spring Cloud Gateway集成SpringDoc,集中管理微服務(wù)API

    Spring Cloud Gateway集成SpringDoc,集中管理微服務(wù)API

    Spring Cloud微服務(wù)集成SpringDoc,在Spring Cloud Gateway中統(tǒng)一管理微服務(wù)的API,微服務(wù)上下線時自動刷新SwaggerUi中的group組。 框架 版本 Spring Boot 3.1.5 Spring Cloud 2022.0.4 Spring Cloud Alibaba 2022.0.0.0 Spring Doc 2.2.0 Nacos Server 2.2.3 公共模塊里的配置是之前文章中提到的內(nèi)容,加了一個webmvc和we

    2024年04月28日
    瀏覽(18)
  • Spring Cloud Gateway集成Nacos作為注冊中心和配置中心

    本篇文章將介紹Spring Cloud Alibaba體系下Spring Cloud Gateway的搭建,服務(wù)注冊中心和分布式配置中心使用Nacos,后續(xù)將會持續(xù)更新,介紹集成Sentinel,如何做日志鏈路追蹤,如何做全鏈路灰度發(fā)布設(shè)計(jì),以及Spring Cloud Gateway的擴(kuò)展等。 ? Spring Boot,Spring Cloud,Discovery,Config等基礎(chǔ)依

    2024年02月11日
    瀏覽(507)
  • Sentinel Dashboard集成Nacos

    Sentinel Dashboard集成Nacos

    當(dāng)項(xiàng)目上Sentinel Dashboard做流量監(jiān)控的時候,我們可以通過Sentinel控制臺修改限流配置,但當(dāng)我們使用Nacos作為配置中心動態(tài)配置流控規(guī)則的時候,問題就來了。 首先我們要明白,Sentinel Dashboard的配置是從機(jī)器的內(nèi)存中加載的,如果使用Nacos、Apollo、Zookeeper等作為我們動態(tài)加載限

    2024年02月15日
    瀏覽(15)
  • 【Spring Cloud Gateway】⑥SpringBoot3.x集成SpringDoc指南

    【Spring Cloud Gateway】⑥SpringBoot3.x集成SpringDoc指南

    Spring Cloud Gateway 使用 Netty 作為嵌入式服務(wù)器,并基于響應(yīng)式 Spring WebFlux 。做為微服務(wù)網(wǎng)關(guān),多個微服務(wù)把 API 掛在 Gateway 上,如果查看某個 API 的 Swagger 還要去各個子微服務(wù)中去查看,就很不方便,如果能在 Gateway 上直接查看各個微服務(wù)的 API 文檔,會方便很多,本文以截至

    2024年02月14日
    瀏覽(23)
  • Spring Cloud Gateway集成Actuator的安全漏洞和解決方案

    Spring Cloud Gateway是一個基于Spring Boot2.0和Spring WebFlux的API網(wǎng)關(guān),它可以將請求轉(zhuǎn)發(fā)到多個微服務(wù)并對請求進(jìn)行路由、過濾和修改。Spring Cloud Gateway集成Actuator后可以提供更多的監(jiān)控和管理功能,但是也可能導(dǎo)致安全漏洞。 最近線上環(huán)境出現(xiàn)一起安全事件,就是由于Spring Cloud Gat

    2024年02月09日
    瀏覽(17)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包