我正在使用 Spring Boot + Cloud | Zuul 代理(org.springframework.cloud:spring-cloud-starter-zuul:1.0.0.RELEASE)。我有以下配置。
info:
component: Zuul Server
endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
zuul:
ignoredServices: "*"
proxy:
mapping: /api/v1
addProxyHeaders: true
routes:
service:
path: /service/**
serviceId: service
stripPrefix: false
server:
port: 8765
logging:
level:
ROOT: INFO
org.springframework.web: INFO
eureka:
instance:
preferIpAddress: true
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
我希望访问 URL 服务为http://localhost:8765/api/v1/service,如上述配置中所做的那样(参考:https ://github.com/joshlong/microservices-lab/blob/master/api-网关/网关/src/main/resources/application.yml)。
但这不起作用,URL http://localhost:8765/service有效。
有没有办法实现这一点,因为我不希望各个服务具有 /api/v1 上下文。