码上敲享录 > springcloud开发经验分享 > zuul 配置路由转发 报错HTTP Status 404 – Not Found

zuul 配置路由转发 报错HTTP Status 404 – Not Found

上一章章节目录下一章 2020-07-05已有3940人阅读 评论(0)

zuul 配置路由转发 报错HTTP Status 404 – Not Found


下面是zuul路由转发的properties配置文件(报错404的文件)

#start

server.port=80

eureka.client.service-url.defaultZone = http://localhost:8761/eureka/

spring.application.name=service-zuul


zuul.routes.dgfy.path=/dgfy/**

zuul.routes.dgfy.service-id=service-dgfy


zuul.routes.srfy.path=/srfy/**

zuul.routes.srfy.service-id=service-srfy

#end


其中服务名为service-dgfy和service-srfy的服务配置了server.servlet.context-path项

服务名service-dgfy配置文件配置了server.servlet.context-path=dgfy

服务名service-srfy配置文件配置了server.servlet.context-path=srfy


原来需要通过zuul来配置前缀路径


zuul默认给我们如下的跳转规则:


http://localhost:8080/api-a/my/mm  ====》http://localhost:8080/my/mm


我们可以通过设置stripPrefix来决定是否需要前缀,true是不加前缀(默认),false就会添加到路径上。


跳转规则如下:

http://localhost:8080/api-a/my/mm  ====》http://localhost:8080/api-a/my/mm


修改properties配置文件

server.port=80

eureka.client.service-url.defaultZone = http://localhost:8761/eureka/

spring.application.name=service-zuul


zuul.routes.dgfy.path=/dgfy/**

zuul.routes.dgfy.service-id=service-dgfy

zuul.routes.dgfy.strip-prefix=false


zuul.routes.srfy.path=/srfy/**

zuul.routes.srfy.service-id=service-srfy

zuul.routes.srfy.strip-prefix=false







向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交