。如图所示, 我在gateway中使用了上述路由、断言和过滤器。接着我在服务模块smiling-auth中写了一个测试接口,测试是否能通过gateway访问到模块中的接口。如下图所示,是我在apipost中的测试。
所有配置都是没有错误的。
解决办法:
在gateway中添加如下依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>
nacos兼容feign,feign集成ribbon,默认实现负载均衡;但是nacos不兼容springcloud gateway自带的ribbon,所以通过上述两个依赖,解决该问题