forked from yudaocode/SpringBoot-Labs
-
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
YunaiV
committed
Feb 29, 2020
1 parent
c12f257
commit 84a92f9
Showing
6 changed files
with
120 additions
and
2 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
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
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,58 @@ | ||
<?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"> | ||
<parent> | ||
<artifactId>labx-08</artifactId> | ||
<groupId>cn.iocoder.springboot.labs</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>labx-08-sc-gateway-demo10-troubleshooting</artifactId> | ||
|
||
<properties> | ||
<spring.boot.version>2.2.4.RELEASE</spring.boot.version> | ||
<spring.cloud.version>Hoxton.SR1</spring.cloud.version> | ||
<spring.cloud.alibaba.version>2.2.0.RELEASE</spring.cloud.alibaba.version> | ||
</properties> | ||
|
||
<!-- | ||
引入 Spring Boot、Spring Cloud、Spring Cloud Alibaba 三者 BOM 文件,进行依赖版本的管理,防止不兼容。 | ||
在 https://dwz.cn/mcLIfNKt 文章中,Spring Cloud Alibaba 开发团队推荐了三者的依赖关系 | ||
--> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>${spring.boot.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring.cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-alibaba-dependencies</artifactId> | ||
<version>${spring.cloud.alibaba.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<!-- 引入 Spring Cloud Gateway 相关依赖,使用它作为网关,并实现对其的自动配置 --> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-gateway</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
...eshooting/src/main/java/cn/iocoder/springcloud/labx08/gatewaydemo/GatewayApplication.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,13 @@ | ||
package cn.iocoder.springcloud.labx08.gatewaydemo; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class GatewayApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(GatewayApplication.class, args); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
labx-08/labx-08-sc-gateway-demo10-troubleshooting/src/main/resources/application.yaml
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,35 @@ | ||
server: | ||
port: 8888 | ||
|
||
spring: | ||
application: | ||
name: gateway-application | ||
|
||
cloud: | ||
# Spring Cloud Gateway 配置项,对应 GatewayProperties 类 | ||
gateway: | ||
# 路由配置项,对应 RouteDefinition 数组 | ||
routes: | ||
- id: yudaoyuanma # 路由的编号 | ||
uri: http://www.iocoder.cn # 路由到的目标地址 | ||
predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组 | ||
- Path=/blog | ||
filters: | ||
- StripPrefix=1 | ||
- id: oschina # 路由的编号 | ||
uri: https://www.oschina.net # 路由的目标地址 | ||
predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组 | ||
- Path=/oschina | ||
filters: # 过滤器,对请求进行拦截,实现自定义的功能,对应 FilterDefinition 数组 | ||
- StripPrefix=1 | ||
|
||
# Reactor Netty 相关配置 | ||
httpserver: | ||
wiretap: true | ||
httpclient: | ||
wiretap: true | ||
|
||
logging: | ||
level: | ||
reactor.netty: DEBUG | ||
org.springframework.cloud.gateway: TRACE |
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