Open LuoYingxiong opened 8 months ago
聚合网关,你可以用这个
https://doc.xiaominfo.com/docs/middleware-sources/spring-cloud-gateway/spring-gateway-introduction
https://doc.xiaominfo.com/docs/blog/gateway/knife4j-gateway-introduce
多谢!使用你们提供的新插件knife4j-gateway-spring-boot-starter的【服务发现】模式确实解决了我的问题,但是出现了新的问题,在网关聚合接口文档的服务下拉框里,服务名出现了重复,请看视频:
https://github.com/xiaoymin/knife4j/assets/35752648/0421d968-60ae-4c3f-9f86-57fcb3a433af
我的项目框架信息如下: Spring Boot 版本: 2.3.12.RELEASE Spring Cloud 版本: Hoxton.SR12 auth-server、service-admin微服务使用的 knife4j-micro-spring-boot-starter版本 :2.0.9
Spring Cloud Gateway网关配置如下:
刚才尝试了knife4j-gateway-spring-boot-starter 4.5.0版本,依然存在上述问题
你可以在knife4j-gateway里面debug看看,获取服务列表的时候,为什么为出现重复。spring cloud config我并没有兼容测试过,目前是对nacos、eureka做过集成测试
你可以在knife4j-gateway里面debug看看,获取服务列表的时候,为什么为出现重复。spring cloud config我并没有兼容测试过,目前是对nacos、eureka做过集成测试
我测试过了,和spring cloud config 没关系,即使我把配置写在gateway工程的bootstrap.yml也会出现同样的问题。源码层面的调试还有待观察
我有gateway、auth-server、service-admin三个微服务,在Gateway上做了knife4j的微服务接口文档聚合。 在gateway中分别为auth-server、service-admin做了路由配置。如下 遇到的问题是: 路由配置的首个微服务不能访问时,从网关访问knife4j首页就一片空白,影响我切到正常服务的接口文档。 请看视频:
https://github.com/xiaoymin/knife4j/assets/35752648/098641fd-ad09-48c4-a1e2-eb4bd7b09bbb
但是我把网关的依赖更换成原生的Swagger(不改变任何代码),就没有有上述问题(虽然首页会报错,但不影响我从下拉框切换到其他服务的接口文档) 请看视频:
https://github.com/xiaoymin/knife4j/assets/35752648/753d657d-f9a4-4e8c-b1b1-69cda69d202c
还请修复一下这个页面展示的bug!!
如下是我Gateway网关的依赖和knife4j的配置代码 (knife4j版本:2.0.9)
pom.xml
路由配置文件:
Swagger 配置代码: