java - 由于 netty 问题,spring cloud gateway 无法路由
问题描述
我比较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;
就是这样。任何帮助将不胜感激!
解决方案
我有同样的问题,我做了调查,我发现 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>
推荐阅读
- node.js - 如何从 dymamiczone strapi 书架中仅获取一个组件
- typescript - 在 Azure 函数上下文中访问绑定中的其他属性
- django - 如何在 Django 中检查或设置房间可用性
- apache-kafka - 读取 Kafka 消息并设置该消息由客户端处理
- python - 如何仅合并熊猫数据框中某列的行中没有值的行
- php - 模式上的更新按钮不起作用codeigniter ajax
- r - 函数不处理 R 中的输入参数
- javascript - CSV 到使用 Java/Javascript 的自定义 XML
- android - Android getLastKnownLocation 不更新
- php - PHP preg_split 用于带有大写和自定义字符的新行