在spring cloud中使用gateway报错404(踩坑)
在我写一个spring cloud小demo时,在浏览器访问报错中报错404,让我百思不得其解,
以下是错误代码展示
teacher业务
@RestController @RequestMapping("/teacher") public class Tcontroller { @PostMapping public String pageTeacher(){ return "查询成功"; }
teacher配置文件
server: port: 8081 spring: application: name: techerServer cloud: nacos: server-addr: localhost:8848
gateway配置文件
server: port: 10010 spring: application: name: gateway-server cloud: nacos: server-addr: localhost:8848 gateway: routes: - id: techer-server uri: lb://techerServer predicates: - Path=/teacherserver/**
在上述gateway配置文件中出现的错误
- Path=/teacherserver/**
正确是应该是
-Path=/teacher/**
Path应该与controller对应
当然,这是我粗心大意在出现的问题,写下笔记引以为戒
下一篇:
设置cpolar远程访问本地网页