• spring cloud gateway


    pom

    <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-consul-discovery</artifactId>
    </dependency>

    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webflux</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix -->
    <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
    </dependency>

     pom注意事项

    必须去除mvc依赖

    如果是springboot去除 spring-boot-starter-web 

    启动项


    @SpringCloudApplication
    public class CousulgatewayApplication {

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

    配置文件

    server:
    port: 8083

    #服务名
    spring:
    application:
    name: gateway-service
    cloud:
    gateway:
    routes:
    - id: consulserver
    # 重点!/info必须使用http进行转发,lb代表从注册中心获取服务
    uri: lb://consulserver
    predicates:
    # 重点!转发该路径!,/userapi/**,
    - Path=/consulserver/**
    # http://localhost:6601/userapi/user/users/2, 必须加上StripPrefix=1,否则访问服务时会带上userapi
    #而不是我们期望的去掉userapi,只保留**部分
    filters:
    - StripPrefix=1
    discovery:
    locator:
    enabled: true
    consul:
    host: localhost
    port: 8500
    discovery:
    register: false
    参考文件https://blog.csdn.net/russle/article/details/80962066

     https://blog.csdn.net/qq_36752632/article/details/79656716

  • 相关阅读:
    k8s的基本概念与基本功能
    STM32F030看门狗
    STM32F030低功耗
    STM32开发脱坑记
    ubuntu下安装wine并运行source insight
    Linux下使用Eclipse搭建ARM开发环境
    linux下的find文件查找命令与grep文件内容查找命令(转)
    STM32F030 BootLoader与应用程序的跳转设置
    MCU开发之MDK-ARM总结
    IIC协议总结
  • 原文地址:https://www.cnblogs.com/tflike/p/10033290.html
Copyright © 2020-2023  润新知