我第一次使用spring cloud gateway。我的服务端点是http://localhost:8080/student/getlist
问题是,当我尝试使用云网关调用我的服务时,它给了我 404。尤里卡正确显示了服务 URL
我的网关属性如下
spring.application.name=gateway
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
server.port=8085
management.endpoints.web.exposure.include=*
spring.cloud.gateway.discovery.locator.enabled=true
spring.cloud.gateway.routes.id=student-service
spring.cloud.gateway.routes.uri=lb://student-service
spring.cloud.gateway.routes.predicates.Path=/student/**
下面是网关中的执行器路由
[{"route_id":"CompositeDiscoveryClient_GATEWAY","route_definition":{"id":"CompositeDiscoveryClient_GATEWAY","predicates":[{"name":"Path","args":{"pattern":"/GATEWAY/**"}}],"filters":[{"name":"RewritePath","args":{"regexp":"/GATEWAY/(?<remaining>.*)","replacement":"/${remaining}"}}],"uri":"lb://GATEWAY","order":0},"order":0},{"route_id":"CompositeDiscoveryClient_STUDENT-SERVICE","route_definition":{"id":"CompositeDiscoveryClient_STUDENT-SERVICE","predicates":[{"name":"Path","args":{"pattern":"/STUDENT-SERVICE/**"}}],"filters":[{"name":"RewritePath","args":{"regexp":"/STUDENT-SERVICE/(?<remaining>.*)","replacement":"/${remaining}"}}],"uri":"lb://STUDENT-SERVICE","order":0},"order":0}]
我试图通过网关调用服务端点
http://localhost:8085/student/getlist
上面的 URL 但这不起作用。我究竟做错了什么。任何微服务都没有上下文路径。示例代码在
https://github.com/ojith97/sample.git