【问题标题】:spring cloud gateway fails to route due to netty issue由于 netty 问题,spring cloud gateway 无法路由
【发布时间】:2019-04-15 03:02:09
【问题描述】:

我对@9​​87654321@ 比较陌生,我正在为此建立一个 POC。 我为此制作了一个示例网关应用程序和一个微服务应用程序。我已验证微服务应用程序运行良好并可通过port: 8080访问

两个应用都运行良好。因此我不在这里分享POMs。 但是请参阅下面的代码详细信息。

网关

application.yml

server:
  port: 8081

spring:
  cloud:
    gateway:
      routes:
      - id: microserviceFirst
        uri: localhost:8080
        predicates:
        - Path= /first

management:
  endpoints:
    web:
      exposure:
        include: "*"

the springboot app:

package com.ey.springCloudGateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringCloudGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringCloudGatewayApplication.class, args);
    }
}

微服务应用

application.properties

spring.application.name="microserviceFirst"
server.port=8080

springboot file

package com.ey.microserviceFirst;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class MicroserviceFirstApplication {

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public Map<String, Object> home() {
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("id", UUID.randomUUID().toString());
        model.put("content", "Hello World");
        return model;
    }

    public static void main(String[] args) {
        SpringApplication.run(MicroserviceFirstApplication.class, args);
    }
}

我正在尝试使用邮递员访问localhost:8081/first。以下是错误。

java.lang.NoSuchMethodError: reactor.netty.http.client.HttpClient.noChunkedTransfer()Lreactor/netty/http/client/HttpClient;

就是这样。 任何帮助将不胜感激!

【问题讨论】:

  • 这是一个已知问题,已修复,待发布
  • 是的!甚至我今天也在那里发表评论并了解了。

标签: java spring-boot spring-cloud spring-cloud-gateway


【解决方案1】:

我有同样的问题,我做了调查,我发现 spring boot(父母和网关云)的版本不同,然后我可以在这个页面(https://www.javainuse.com/spring/cloud-gateway)中看到示例和这个其他页面(https://blog.csdn.net/h363659487/article/details/102780475) 解决方案。

希望对你有所帮助。

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>

    <version>2.1.3.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-gateway</artifactId>

        <version>2.1.3.RELEASE</version>
</dependency>

【讨论】:

    猜你喜欢
    • 2019-08-03
    • 2019-03-31
    • 2023-01-21
    • 1970-01-01
    • 1970-01-01
    • 2019-09-23
    • 2021-11-19
    • 2023-04-02
    • 2019-10-29
    相关资源
    最近更新 更多