Spring 云 Zuul 反向代理路由不适用于版本化和上下文路径指定的其余应用程序

Spring cloud Zuul reverse proxy routing not working with versioned and context path specified rest application

创建了一个 spring 引导应用程序并设置了上下文路径和版本。然后添加用于路由的zuul代理的配置。我参考 spring 示例 Routing and Filtering。 application.properties 中唯一的区别是添加了 contextPath 和版本。还使用 @EnableZuulProxy 注释启用了 zuul 代理。但是路由不起作用。当我删除版本和上下文时它起作用了。

application.properties 文件

server.port=8080
server.servlet.context-path=/app1
version=v1
zuul.routes.foos.path=/api/**
zuul.routes.foos.url=http://localhost:8081/app2/v1/

问题终于解决了。忘记在 zuul 路径中添加版本。需要在 zuul 路径中也添加 version

application.properties

server.port=8080
server.servlet.context-path=/app1
version=v1
zuul.routes.foos.path=/v1/api/**
zuul.routes.foos.url=http://localhost:8081/app2/v1/