Java Spring Boot Zuul API网关返回404响应
我正在尝试设置Spring Boot Zuul 2.2,以便能够向注册到Eureka的服务发送请求,从而为Zuul所知 我可以通过Zuul访问服务的Swagger UI,但当我尝试向服务发送请求时,会得到Java Spring Boot Zuul API网关返回404响应,java,spring,spring-boot,netflix-eureka,netflix-zuul,Java,Spring,Spring Boot,Netflix Eureka,Netflix Zuul,我正在尝试设置Spring Boot Zuul 2.2,以便能够向注册到Eureka的服务发送请求,从而为Zuul所知 我可以通过Zuul访问服务的Swagger UI,但当我尝试向服务发送请求时,会得到404 HTTP状态-未找到响应 服务的配置如下: management: endpoints: web: exposure: include: "*" endpoint: health: show-details: always
404 HTTP状态-未找到响应
服务的配置如下:
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8761/eureka
instance:
preferIpAddress: true
eureka:
instance:
preferIpAddress: true
client:
registerWithEureka: true
fetchRegistry: true
spring:
application:
name: app-zuul
management:
endpoints:
web:
exposure:
include: routes,filters
endpoint:
health:
show-details: always
Zuul应用程序的配置如下:
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8761/eureka
instance:
preferIpAddress: true
eureka:
instance:
preferIpAddress: true
client:
registerWithEureka: true
fetchRegistry: true
spring:
application:
name: app-zuul
management:
endpoints:
web:
exposure:
include: routes,filters
endpoint:
health:
show-details: always
最后,Eureka配置:
eureka:
client:
registerWithEureka: false
fetchRegistry: false
spring:
application:
name: app-eureka
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
我可以通过直接向用户服务发送请求http://localhost:3335/api/v1/...
但是当我尝试请求时,我收到了一个404
http://localhost:8763/app-user/api/v1/…
我缺少一些配置吗?您必须在zuul服务器属性中添加zuul路由:
例如:
正确添加路由后,您将能够访问URL
参考:
要在路线中使用eureka应用程序名称,请添加如下路线:
zuul:
routes:
app-user: #app name
path: /app-user/** #app-url
app-user:
serviceId: APP-USER #eureka serviceID
参考资料:但我不能硬核url?尤里卡知道这个网址吗?那这应该是你的问题。你能告诉我你到底在找什么吗。用参考更新了答案。