dromara / Sa-Token

一个轻量级 Java 权限认证框架,让鉴权变得简单、优雅!—— 登录认证、权限认证、分布式Session会话、微服务网关鉴权、单点登录、OAuth2.0
https://sa-token.cc
Apache License 2.0
16.67k stars 2.62k forks source link

Spring Cloud Gateway 2022已经使用reactor-core 3.x,WebFlux框架高度依赖Reactor,**建议保持和 Gateway Reactor版本同步** #622

Open aaric opened 6 months ago

aaric commented 6 months ago

使用版本:

latest (io.projectreactor:reactor-core:3.1.4.RELEASE 发布年份2018-02-15)

报错信息:

ClassNotFoundException: reactor.util.context.ContextView

希望结果:

Spring Cloud Gateway不被影响

复现步骤:

1.正常搭建网关,引入依赖

ext {
    // https://github.com/alibaba/spring-cloud-alibaba/wiki/版本说明#毕业版本依赖关系推荐使用
    springCloudVersion = "2022.0.0"
    springCloudAlibabaVersion = "2022.0.0.0"
    knife4jVersion = "4.5.0"
    saTokenVersion = "1.37.0"
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion"
        mavenBom "com.alibaba.cloud:spring-cloud-alibaba-dependencies:$springCloudAlibabaVersion"
        mavenBom "com.github.xiaoymin:knife4j-dependencies:$knife4jVersion"
        mavenBom "cn.dev33:sa-token-dependencies:$saTokenVersion"
     }
}

dependencies {
    implementation project(":v2x-common")

    implementation "com.github.xiaoymin:knife4j-gateway-spring-boot-starter"

    // Fixed: ClassNotFoundException: reactor.util.context.ContextView
    //implementation "io.projectreactor:reactor-core:3.5.4"

    implementation "org.springframework.cloud:spring-cloud-starter-gateway"
    implementation "org.springframework.cloud:spring-cloud-starter-loadbalancer"
    implementation "org.springframework.cloud:spring-cloud-starter-bootstrap"
    implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery"
    implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config"

    implementation "org.springframework.boot:spring-boot-starter-log4j2"
}

2.网关启动报错

ClassNotFoundException: reactor.util.context.ContextView

3.原因分析 最新的cn.dev33:sa-token-dependencies:1.38.0使用的reactor-core版本还是<reactor-core.version>3.1.4.RELEASE</reactor-core.version>,Spring Cloud Gateway 2022已经使用reactor-core 3.x,WebFlux框架高度依赖Reactor,建议保持和 Gateway Reactor版本同步

< 备注:如果复现步骤比较复杂,请将 demo 上传到 gitee 并留下地址 >

aaric commented 6 months ago

Snipaste_2024-05-15_15-32-51

aaric commented 6 months ago

Snipaste_2024-05-15_15-34-03