问题记录:GateWay启动报错

本文详细记录了在使用SpringBoot 2.2.1、SpringCloud HoxtonSR6和GateWay 2.2.4版本时遇到的启动失败问题,以及在尝试升级WebFulx和reactor-netty后的运行错误。最终通过升级SpringBoot至2.3.1版本解决了所有问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

版本:
  • SpringCloud: Hoxton SR6
  • GateWay:2.2.4 其它版本也一样(2.x)
  • SpringBoot:2.2.1
依赖:
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-consul-discovery</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>jsr305</artifactId>
                <groupId>com.google.code.findbugs</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-gateway</artifactId>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>
</dependencies>
启动直接报错:

Correct the classpath of your application so that it contains a single, compatible version of reactor.netty.resources.ConnectionProvider

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-30 17:35:32.552 ERROR 67984 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.cloud.gateway.config.GatewayAutoConfiguration$NettyConfiguration.gatewayHttpClient(GatewayAutoConfiguration.java:622)

The following method did not exist:

    reactor.netty.resources.ConnectionProvider.elastic(Ljava/lang/String;Ljava/time/Duration;Ljava/time/Duration;)Lreactor/netty/resources/ConnectionProvider;

The method's class, reactor.netty.resources.ConnectionProvider, is available from the following locations:

    jar:file:/E:/warehouse/io/projectreactor/netty/reactor-netty/0.9.1.RELEASE/reactor-netty-0.9.1.RELEASE.jar!/reactor/netty/resources/ConnectionProvider.class

It was loaded from the following location:

    file:/E:/warehouse/io/projectreactor/netty/reactor-netty/0.9.1.RELEASE/reactor-netty-0.9.1.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of reactor.netty.resources.ConnectionProvider
单独升级WebFulx和reactor-netty可以正常启动且访问正常
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webflux</artifactId>
    <version>5.2.7.RELEASE</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.netty</groupId>
    <artifactId>reactor-netty</artifactId>
    <version>0.9.8.RELEASE</version>
</dependency>
但运行过程中一直报如下错误

java.lang.NoSuchMethodError: org.springframework.http.server.reactive.ServerHttpResponse.setRawStatusCode(Ljava/lang/Integer;)Z

020-06-30 17:39:33.021 ERROR 63684 --- [ctor-http-nio-2] reactor.netty.http.server.HttpServer     : [id: 0xe544fb4b, L:/192.168.7.254:9527 - R:/192.168.7.254:61632] 

java.lang.NoSuchMethodError: org.springframework.http.server.reactive.ServerHttpResponse.setRawStatusCode(Ljava/lang/Integer;)Z
	at org.springframework.web.reactive.function.server.DefaultServerResponseBuilder$AbstractServerResponse.writeStatusAndHeaders(DefaultServerResponseBuilder.java:356) ~[spring-webflux-5.2.7.RELEASE.jar:5.2.7.RELEASE]
	at org.springframework.web.reactive.function.server.DefaultServerResponseBuilder$AbstractServerResponse.writeTo(DefaultServerResponseBuilder.java:344) ~[spring-webflux-5.2.7.RELEASE.jar:5.2.7.RELEASE]
	at org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler.write(AbstractErrorWebExceptionHandler.java:311) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler.lambda$handle$2(AbstractErrorWebExceptionHandler.java:264) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:118) ~[reactor-core-3.3.0.RELEASE.jar:3.3.0.RELEASE]
	at ...
最终解决方法就是将SpringBoot升级到最新版本2.3.1,一切正常
父依赖
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>2.3.1.RELEASE</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>
### 解决方案概述 在安装 Ceph 的 Dashboard 组件时可能会遇到多种错误,这些错误通常涉及权限配置、依赖项缺失或网络连接问题。以下是针对常见错误的分析和解决方案。 #### 权限不足导致的错误 如果在启用 Ceph Dashboard 时收到类似于 `Permission denied` 或其他与权限相关的错误消息,则可能是由于未正确设置管理员密钥环文件的路径所致。可以通过以下命令重新指定密钥环位置并授予必要权限: ```bash sudo ceph dashboard set-login-credentials admin <password> --keyring=/etc/ceph/ceph.client.admin.keyring ``` 此操作会更新登录凭证并将密钥环绑定到特定用户账户上[^1]。 #### HTTP异常引发的服务启动失败 当尝试访问Dashboard界面却返回诸如“503 Service Unavailable”的状态码时,这表明后台服务未能正常初始化完成。一种可能的原因是没有足够的资源分配给容器实例或者存在IP地址冲突等问题。对于这种情况,建议按照下面的方法排查处理: 1. **检查日志记录** 查看相关进程的日志输出可以帮助定位具体原因: ```bash journalctl -u ceph-dashboard.service ``` 2. **重启关联组件** 如果发现某些模块处于非活动状态,则应依次重置它们的状态直到整个系统恢复正常为止: ```bash systemctl restart ceph-mon@<mon-id> systemctl restart ceph-mgr@<mgr-id> ``` 另外需要注意的是,在多节点环境中还需要同步时间戳以及调整防火墙策略以便允许外部请求穿透到达内部监听端口[^2]。 #### 使用Rook简化部署过程中的复杂度 考虑到手动搭建环境容易引入人为失误从而增加调试难度的情况,采用基于 Kubernetes 的 Rook 工具来自动编排各项任务不失为明智之举。通过定义YAML描述文件即可快速创建包含所需特性的集群结构而无需逐一手动执行每一步骤。例如要新增支持对象网关功能只需简单修改参数选项即可实现无缝扩展能力提升[^4]: ```yaml apiVersion: ceph.rook.io/v1 kind: CephCluster metadata: name: rook-ceph namespace: rook-ceph spec: ... services: type: LoadBalancer dashboardsEnabled: true objectStore: gateway: sslCertificateRef: name: my-cert-secret ``` 以上方法能够有效减少因误配而导致的各种潜在隐患发生几率的同时还极大提高了工作效率降低了维护成本。 ---
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

DeathAndLife

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

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

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

打赏作者

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

抵扣说明:

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

余额充值