Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 弹簧靴&x2B;Cloud | Zuul Proxy |附加URL/重写_Spring Boot_Spring Cloud_Netflix Zuul - Fatal编程技术网

Spring boot 弹簧靴&x2B;Cloud | Zuul Proxy |附加URL/重写

Spring boot 弹簧靴&x2B;Cloud | Zuul Proxy |附加URL/重写,spring-boot,spring-cloud,netflix-zuul,Spring Boot,Spring Cloud,Netflix Zuul,Iam使用springboot+Cloud | Zuul代理(org.springframework.Cloud:springcloudstarterzuul:1.0.0.RELEASE)。我有以下配置 info: component: Zuul Server endpoints: restart: enabled: true shutdown: enabled: true health: sensitive: false zuul: ignored

Iam使用springboot+Cloud | Zuul代理(org.springframework.Cloud:springcloudstarterzuul: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与上面的配置(ref:)一样

但这不起作用,URL起作用


有没有办法做到这一点,因为我不希望单个服务具有/api/v1上下文。

不确定从哪里获得
zuul.proxy.*
选项。它们是无效的
zuul.addProxyHeaders
有效


您需要的是
zuul.prefix=/api/v1
。默认设置是在转发时去掉该前缀。所以
/api/v1/service
转发给
/service

@spencergib那么/api/v2/service会发生什么呢?维护到同一API的不同版本的路由映射的最佳方法是什么?