赞
踩
在我写一个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
- 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对应
当然,这是我粗心大意在出现的问题,写下笔记引以为戒
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。