POM file dependency
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!--gateway fhadmin.org-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<version>3.0.2</version>
</dependency>
<!--spring-boot fhadmin.org-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
The related dependencies of Nacos I added in the parent component are as follows:
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>${nacos.version}</version>
</dependency>
<!--alibaba fhadmin.org-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${nacos.version}</version>
</dependency>
The version of Nacos is as follows:
<properties>
<nacos.version>2021.1</nacos.version>
</properties>
The application.yml file of gateway is configured as follows:
#fhadmin.org
server:
port: 9040
spring:
application:
name: gateway
cloud:
gateway:
routes:
- id: consumer
uri: lb://consumer
# uri: http://localhost:9010
predicates:
- Path=/**
nacos:
discovery:
server-addr: localhost:8848
metadata:
preserved.heart.beat.interval: 3
preserved.heart.beat.timeout: 6
preserved.ip.delete.timeout: 9
When I pass URI: http://localhost:9010 When calling a service, it can be called, but when I use URI LB:// consumer, I cannot call the service, and an error 503 is reported
The solution is:
Add feign dependency.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<version>3.0.2</version>
</dependency>
<!--fegin fhadmin.cn-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>3.0.2</version>
</dependency>
<!-- Feign Client for loadBalancing -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Guess the reason: Nacos is compatible with feign. Feign integrates ribbon and realizes load balancing by default; Maybe Nacos is not compatible with the ribbon of springcloud gateway.
Read More:
- Spring Cloud Hoxton.SR9 gateway and reactor-netty 0.9.0.RELEASE is Incompatible [How to Solve]
- [Solved] Spring Cloud Use Ribbon Error: No instances available for XXX
- Spring cloud remote connect Nacos error [How to Solve]
- Springcloud builds a gateway and starts Error [Solved]
- Hystrix fuse of spring cloud system
- [Solved] Spring cloud zuul Error: com.netflix.zuul.exception.ZuulException
- Spring cloud Netflix hystrix/acutor/hystrix.stream Error ut005023
- Gateway Error: allowedOrigins cannot contain the special value “*“
- Zuul Gateway Failed to Import Dependency [How to Solve]
- How to Solve Spring integrate Seata startup error
- [Solved] Failed to introspect Class [org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfigura
- [Solved] spring boot integrated PageHelper Error
- Solution to the problem of using Alibaba gateway but unable to route successfully
- [Solved] debug error: cloud netflix. eureka. EurekaDiscoveryClientConfiguration (IDEA package normally)
- Spring Security Upgrade to Version 5.5.7, 5.6.4 or Above to Startup Error (Version incompatibility)
- Spring boot real time HTML page
- [Solved] ‘build.plugins.plugin.version‘ for org.springframework.boot:spring-boot-maven-plugin is missing.
- Eclipse relies on spring boot configuration processor, and there is no prompt for writing properties and YML
- [Solved] Failed to bind properties under ‘spring.servlet.multipart.file-size-threshold‘ to
- Ruoyi-cloud Integrated mybatis-plus Error: Unknown column ‘search_value‘ in ‘field list‘