-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> | ||
<groupId>com.itmuch.cloud</groupId> | ||
<artifactId>microservice-gateway-zuul-reg-exp</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<!-- 引入spring boot的依赖 --> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>1.4.2.RELEASE</version> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>1.8</java.version> | ||
</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> | ||
|
||
<!-- 引入spring cloud的依赖 --> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>Camden.SR2</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<!-- 添加spring-boot的maven插件 --> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
24 changes: 24 additions & 0 deletions
24
microservice-gateway-zuul-reg-exp/src/main/java/com/itmuch/cloud/study/ZuulApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.itmuch.cloud.study; | ||
|
||
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 { | ||
|
||
@Bean | ||
public PatternServiceRouteMapper serviceRouteMapper() { | ||
// 调用构造函数PatternServiceRouteMapper(String servicePattern, String routePattern) | ||
// servicePattern指定微服务的正则 | ||
// routePattern指定路由正则 | ||
return new PatternServiceRouteMapper("(?<name>^.+)-(?<version>v.+$)", "${version}/${name}"); | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ZuulApplication.class, args); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
microservice-gateway-zuul-reg-exp/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
server: | ||
port: 8040 | ||
spring: | ||
application: | ||
name: microservice-gateway-zuul | ||
eureka: | ||
client: | ||
service-url: | ||
defaultZone: http://localhost:8761/eureka/ | ||
instance: | ||
prefer-ip-address: true |