项目需要在Kubernetes上使用SCG,参照网上的教程 spring-cloud-kubernetes与SpringCloud Gateway 做了网关应用,可以正常工作。但我们项目是基于Springboot3.x 的,而原来的教程是基于Springboot 2.x的,升级后发现一直没法发现服务,报503 Service Not Available的异常。查阅了Spring官方文档,估计是原来的依赖不对,改了一下依赖,终于正常了。
正常的依赖如下:
xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-fabric8</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>