春天云网关由于网线问题导致路由失败。

问题描述 投票:0回答:1

我是一个比较新的 spring-cloud-gateway 我正在为同样的事情建立一个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个回答
0
投票

我也有同样的问题,我做了一个调查,我发现spring boot(parental和gateway cloud)的版本是不同的,然后我可以看到在这个页面(https:/www.javainuse.comspringcloud-gateway)的例子和这个其他页面(https:/blog.csdn.neth363659487articledetails102780475。)的解决方案。

希望对大家有所帮助。

<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>
© www.soinside.com 2019 - 2024. All rights reserved.