项目之前使用的时候springgboot-2.6.13,gateway-3.1.4。然后安全检查的时候说
软件:spring-web(jar) 5.3.23
命中:["spring-web(jar) version less than 5.3.32"]
路径:/opt/gateway-0.0.1-SNAPSHOT.jar(BOOT-INF/lib/spring-web-5.3.23.jar)
解决办法就是要升级spring-web的版本
因为springboot-2.6.13已经不再维护了,直接从gateway的依赖里面去掉spring-web,然后重新引入spring-web-5.3.33会报一个错误
[ctor-http-nio-5] reactor.netty.http.server.HttpServer : [49b02120-1, L:/0:0:0:0:0:0:0:1:10215 - R:/0:0:0:0:0:0:0:1:57712]
java.lang.NoSuchMethodError: reactor.netty.http.server.HttpServerRequest.hostPort()I
at org.springframework.http.server.reactive.ReactorServerHttpRequest.resolveBaseUrl(ReactorServerHttpRequest.java:84) ~[spring-web-5.3.33.jar:5.3.33]
at org.springframework.http.server.reactive.ReactorServerHttpRequest.initUri(ReactorServerHttpRequest.java:79) ~[spring-web-5.3.33.jar:5.3.33]
at org.springframework.http.server.reactive.ReactorServerHttpRequest.<init>(ReactorServerHttpRequest.java:71) ~[spring-web-5.3.33.jar:5.3.33]
at org.springframework.http.server.reactive.ReactorHttpHandlerAdapter.apply(ReactorHttpHandlerAdapter.java:58) ~[spring-web-5.3.33.jar:5.3.33]
at org.springframework.http.server.reactive.ReactorHttpHandlerAdapter.apply(ReactorHttpHandlerAdapter.java:40) ~[spring-web-5.3.33.jar:5.3.33]
at reactor.netty.http.server.HttpServer$HttpServerHandle.onStateChange(HttpServer.java:985) ~[reactor-netty-http-1.0.24.jar:1.0.24]
at reactor.netty.ReactorNetty$CompositeConnectionObserver.onStateChange(ReactorNetty.java:677) [reactor-netty-core-1.0.24.jar:1.0.24]
最终解决办法
升级springboot的版本到2.7.11
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:2.7.11" // 使用最新的2.7.x版本
mavenBom "org.springframework.cloud:spring-cloud-dependencies:2021.0.7" // 使用最新的2021.0.x版本
}
}
implementation(group: 'org.springframework.cloud', name: 'spring-cloud-starter-gateway', version: '3.1.4'){
exclude group: 'org.springframework', module: 'spring-web'
}
implementation group: 'org.springframework', name: 'spring-web', version: '5.3.34'
implementation 'io.projectreactor.netty:reactor-netty:1.0.25'
版权归原作者 qq_21526409 所有, 如有侵权,请联系我们删除。