一个web项目连接zuul网关连接后台多个服务。
示例:web端使用feignClient
com.mark.demo.security.service; java.util.List; org.springframework.beans.factory.annotation.Value; org.springframework.cloud.netflix.feign.FeignClient; org.springframework.web.bind.annotation.RequestBody; org.springframework.web.bind.annotation.RequestMapping; org.springframework.web.bind.annotation.RequestMethod; org.springframework.web.bind.annotation.RequestParam; com.mark.demo.security.base.PaginateResult; com.mark.demo.security.entity.Menu; com.mark.demo.security.service.hystrix.MenuFeignFallBackFactory; com.mark.demo.security.service.hystrix.MenuFeignServiceHystrix; (name,url,fallbackFactoryMenuFeignFallBackFactory.) () { () ListMenu getMenuTopLever(); () ListMenu getMenuChildren(() pid); () updateMenu( Menu menu); (value,methodRequestMethod.POST) PaginateResultMenu listData(() Menu menu,() pageSize,() currentPage); }
zuul配置:
zuul.stripprefix zuul.routes.menu.pathservicemenu
调试时发现404错误:日志打印zuul No route found for uri:
跟踪代码发现/zuul的默认context-path是/zuul,它会裁剪请求的url
加上一个配置
zuul.servlet-path=/
就可以调通了