BUG记录:springcloud配置网关后,访问接口返回404

项目结构:前端端口8001,访问后端网关端口88,网关配置好跨域问题后,再将请求转发到相应的业务接口。但是配置好了之后,前端访问88端口返回404

网关的application.yml

spring: cloud: nacos: discovery: server-addr: 124.221.226.193:8848 gateway: routes: - id: product_route uri: lb://bearmall-product predicates: - Path=/api/product/** filters: - RewritePath=/api/(?<segment>.*),/$\{segment} - id: admin_route uri: lb://renren-fast predicates: - Path=/api/** filters: - RewritePath=/api/(?<segment>.*),/renren-fast/$\{segment} application: name: bearmall-gateway server: port: 88

 

问题解决:高版本的springboot,在pom文件里需要添加 spring-cloud-starter-loadbalancer 依赖

<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-loadbalancer</artifactId> </dependency>

 


__EOF__

本文作者Teemo-zhao
本文链接https://www.cnblogs.com/teemo-zhao/p/16469400.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   Teemo_zhao  阅读(1228)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
点击右上角即可分享
微信分享提示