• springcloud17---zuul-reg-exp


    package com.itmuch.cloud;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
    import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
    import org.springframework.context.annotation.Bean;
    
    @SpringBootApplication
    @EnableZuulProxy
    public class ZuulApplication {
      public static void main(String[] args) {
        SpringApplication.run(ZuulApplication.class, args);
      }
    
      //正则表达式路由规则:
      //name-version映射成version/name
      //用户微服务通过http://192.168.88.1:7901/simple/1访问,user微服务名字是microservice-provider-user-v1-v2
      //通过http://192.168.88.1:8040/v2/microservice-provider-user-v1/simple/1就可以访问user微服务
      @Bean
      public PatternServiceRouteMapper serviceRouteMapper() {
        return new PatternServiceRouteMapper("(?<name>^.+)-(?<version>v.+$)", "${version}/${name}");
      }
    }
    spring:
      application:
        name: microservice-gateway-zuul
    server:
      port: 8040
    eureka:
      client:
        service-url:
          defaultZone: http://user:password123@localhost:8761/eureka
      instance:
        prefer-ip-address: true
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <parent>
            <groupId>com.itmuch.cloud</groupId>
            <artifactId>microservice-spring-cloud</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </parent>
    
        <artifactId>microservice-gateway-zuul-reg-exp</artifactId>
        <packaging>jar</packaging>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-zuul</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-eureka</artifactId>
            </dependency>
        </dependencies>
    
    </project>
  • 相关阅读:
    HDU 1513 最长子序列
    HDU 3033 分组背包变形(每种至少一个)
    HDU 1712 分组背包
    深度学习
    《将博客搬至CSDN》
    UVa 10917 Dijkstra
    hdu 3839 Ancient Messages (dfs )
    LA 4255 UVa1423 拓扑排序
    poj 2515 差分序列,排列组合
    UVA 10054 the necklace 欧拉回路
  • 原文地址:https://www.cnblogs.com/yaowen/p/9159490.html
Copyright © 2020-2023  润新知