ruoyi源码解析学习 - 微服务版 - ruoyi-gateway

com.ruoyi.gateway

今天简单看看若依的gateway的配置模块干了啥

最近面试很多外包公司,都对低代码平台有点要求,这些代码虽说用起来不费劲,但是其中还是有很多细节能让我学习学习的。(微服务版,上次搞jeecgboot的笔试题差点把我人带走了)

在这里插入图片描述

简单的看一眼,总共分为4个文件夹和1个启动类。

0. pom文件

<parent>
   <groupId>com.ruoyi</groupId>
   <artifactId>ruoyi</artifactId>
   <version>3.6.4</version>
</parent>

dependencies
spring-cloud-starter-gateway
spring-cloud-starter-alibaba-nacos-discovery
spring-cloud-starter-alibaba-nacos-config
spring-cloud-starter-alibaba-sentinel
spring-cloud-alibaba-sentinel-gateway
sentinel-datasource-nacos
spring-boot-starter-actuator
spring-cloud-loadbalancer
kaptcha
ruoyi-common-redis
springdoc-openapi-webflux-ui

1. 先看一眼启动类

emm,没什么特别就加了一个注解,用来剔除数据库的自动配置的。

@SpringBootApplication(exclude = {
   
   DataSourceAutoConfiguration.class })

2. 从头开始看,第一个是config

  • config
    • properties(首先也是一个目录,里面写了一些属性)
    • CaptchaConfig:验证码的配置
    • GatewayConfig:网关限流配置
    • KaptchaTextCreator:验证码文本生成器(这里是no usages的)
    • RouterFunctionConfiguration:路由配置
    • SpringDocConfig:文档的配置类

CaptchaConfig

这里用的是google的kaptcha的包,里面注册了两个bean,一个是default的验证码bean,一个是数字的bean。

GatewayConfig:这里主要是注册了一个自定义的限流处理

@Configuration
public class GatewayConfig{
   
   
    @Bean
    @Order(Ordered.HIGHEST_PRECEDENCE)
    // 这里的SentinelFallbackHandler自定义的限流处理,跳转过去看看
    public SentinelFallbackHandler sentinelGatewayExceptionHandler(){
   
   
        return new SentinelFallbackHandler();
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mtc8n24

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值