跳至主要內容

开发中遇到的各种问题

ChenSino原创小于 1 分钟

1. springcloudgateway负载均衡配置不生效

配置如下,使用lb/serviceid配置负载均衡,一直报错,服务找不到

spring:
  cloud:
    gateway:
      routes:
        - id: mcs
          uri: lb://mcs
         # uri: http://10.10.102.106:2221
          predicates:
            - Path=/mcs/**
          filters:
            - StripPrefix=1

解决方式是引入以下依赖:

<!-- 引入spring-cloud-loadbalancer -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>