在我寫一個(gè)spring cloud小demo時(shí),在瀏覽器訪問報(bào)錯(cuò)中報(bào)錯(cuò)404,讓我百思不得其解,
?
?以下是錯(cuò)誤代碼展示
teacher業(yè)務(wù)
@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配置文件中出現(xiàn)的錯(cuò)誤
- Path=/teacherserver/**
正確是應(yīng)該是
-Path=/teacher/**
Path應(yīng)該與controller對應(yīng)文章來源:http://www.zghlxwxcb.cn/news/detail-756251.html
當(dāng)然,這是我粗心大意在出現(xiàn)的問題,寫下筆記引以為戒文章來源地址http://www.zghlxwxcb.cn/news/detail-756251.html
到了這里,關(guān)于在spring cloud中使用gateway報(bào)錯(cuò)404(踩坑)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!