微服务 spring cloud gateway搭建

gateway组件搭建

pom文件

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <optional>true</optional>
</dependency>

项目配置文件

spring:
  application:
    name: gateway-service
  # 开启 Gateway 服务注册中心服务发现
  cloud:
    gateway:
      discovery:
        locator:
          # 自动根据服务名 提供 路由转发
          enabled: true
          # 服务名小写开启
          lower-case-service-id: true
eureka:
  client:
    serviceUrl:
      defaultZone: http://eureka0:8010/eureka/, http://eureka1:8010/eureka/, http://eureka2:8010/eureka/ # eureka server的地址

logging:
  level:
    org.springframework.cloud.gateway: trace
    org.springframework.http.server.reactive: debug
    org.springframework.web.reactive: debug
    reactor.ipc.netty: debug

server:
  port: 8020

启动类 配置 注解

@EnableEurekaClient
@SpringBootApplication
public class GatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }

}

NOTE: 博客内容供参考学习,如有问题请指正,虚心接纳

发布了11 篇原创文章 · 获赞 0 · 访问量 395

猜你喜欢

转载自blog.csdn.net/qq_41692766/article/details/105538402