About lb failure in gateway

When the request is sent to the corresponding service module through the gateway, a 503 error occurs, that is, the gateway can be started normally, but when the request is sent to obtain data on the page, it is not the corresponding request address.

Solution:

1. First of all, you have to ensure that the access gateway address in the front-end project is correct.

2. Check whether the service and gateway in your nacos are in the same namespace and group.

3. Check whether your configuration is wrong (missing any punctuation or something).

spring:
  cloud:
    gateway:
      routes:
        - id: admin_route
          uri: lb://renren-fast
          predicates:
            - Path=/api/**
          filters:
            - RewritePath= /api/(?<segment>.*),/renren-fast/$\{segment}

4. If the problem has not been solved, add to your pom:

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

Note that it is spring-cloud-starter-loadbalancer, not spring-cloud-loadbalancer! ! ! !

5. If there are other errors, for example, mine is an error message saying:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.  Reason: Failed to determine a suitable driver class

The solution is to add to the startup class:

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

6. If there is a dependency conflict error again, you can add it to your configuration class, that is, yml:

spring:
  main:
    allow-circular-references: true

7. If the above still does not solve your problem, you should carefully check whether your springboot and springcloud versions correspond. Of course, you have already done this step. There is a high probability that there is no problem with your version, but you still have to be careful Check to see if you have been careless somewhere.

8. Basically, after your error message is displayed on the console, you can find out where the problem is based on the error message. If you still can’t solve it yourself, you can only go to Baidu. If Baidu can’t solve it, the best way is to ask Ask those around you.

Guess you like

Origin blog.csdn.net/Hubery_sky/article/details/131751162