zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Swift实现单例
    UIViewContentMode说明
    打开或关闭Mac的隐藏文件的命令。
    struts2-2.3.20以上版本无法正常启动
    eclipse下导入jdk源码
    js 与css script
    eclipse导入jquery包后报错
    ${pageContext.request.contextPath} :JSP取得绝对路径方法
    小米暑期实习在线笔试2015-04-25
    android动态污点分析
  • 原文地址:https://www.cnblogs.com/tflike/p/10033290.html
Copyright © 2011-2022 走看看