Skip to content

Commit 0b0d6f4

Browse files
committed
gateway cloud
1 parent 0f1ba1e commit 0b0d6f4

File tree

14 files changed

+230
-139
lines changed

14 files changed

+230
-139
lines changed

sc-f-gateway-cloud/eureka-server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<parent>
1515
<groupId>com.forezp</groupId>
16-
<artifactId>sc-f-chapter1</artifactId>
16+
<artifactId>sc-f-gateway-cloud</artifactId>
1717
<version>0.0.1-SNAPSHOT</version>
1818
</parent>
1919

sc-f-gateway-cloud/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<modules>
2222
<module>eureka-server</module>
2323
<module>service-hi</module>
24+
<module>service-gateway</module>
2425
</modules>
2526

2627
<properties>

sc-f-gateway-cloud/service-gateway/pom.xml

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,19 @@
1212
<description>Demo project for Spring Boot</description>
1313

1414
<parent>
15-
<groupId>org.springframework.boot</groupId>
16-
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>2.1.0.RELEASE</version>
18-
<relativePath/> <!-- lookup parent from repository -->
15+
<groupId>com.forezp</groupId>
16+
<artifactId>sc-f-gateway-cloud</artifactId>
17+
<version>0.0.1-SNAPSHOT</version>
1918
</parent>
2019

21-
<properties>
22-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24-
<java.version>1.8</java.version>
25-
<spring-cloud.version>Greenwich.M1</spring-cloud.version>
26-
</properties>
27-
2820
<dependencies>
2921
<dependency>
3022
<groupId>org.springframework.cloud</groupId>
31-
<artifactId>spring-cloud-starter-gateway</artifactId>
23+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
3224
</dependency>
3325
<dependency>
3426
<groupId>org.springframework.cloud</groupId>
35-
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
27+
<artifactId>spring-cloud-starter-gateway</artifactId>
3628
</dependency>
3729

3830
<dependency>
@@ -42,18 +34,6 @@
4234
</dependency>
4335
</dependencies>
4436

45-
<dependencyManagement>
46-
<dependencies>
47-
<dependency>
48-
<groupId>org.springframework.cloud</groupId>
49-
<artifactId>spring-cloud-dependencies</artifactId>
50-
<version>${spring-cloud.version}</version>
51-
<type>pom</type>
52-
<scope>import</scope>
53-
</dependency>
54-
</dependencies>
55-
</dependencyManagement>
56-
5737
<build>
5838
<plugins>
5939
<plugin>
@@ -74,5 +54,4 @@
7454
</repository>
7555
</repositories>
7656

77-
7857
</project>

sc-f-gateway-filter/src/main/java/gateway/ElapsedGatewayFilterFactory.java renamed to sc-f-gateway-cloud/service-gateway/src/main/java/com/forezp/servicegateway/ElapsedGatewayFilterFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gateway;
1+
package com.forezp.servicegateway;
22

33
import org.apache.commons.logging.Log;
44
import org.apache.commons.logging.LogFactory;

sc-f-gateway-cloud/service-gateway/src/main/java/com/forezp/servicegateway/ServiceGatewayApplication.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6+
import org.springframework.context.annotation.Bean;
57

68
@SpringBootApplication
9+
@EnableEurekaClient
710
public class ServiceGatewayApplication {
811

912
public static void main(String[] args) {
1013
SpringApplication.run( ServiceGatewayApplication.class, args );
1114
}
15+
16+
@Bean
17+
public ElapsedGatewayFilterFactory elapsedGatewayFilterFactory() {
18+
return new ElapsedGatewayFilterFactory();
19+
}
1220
}

sc-f-gateway-cloud/service-gateway/src/main/resources/application.properties

Whitespace-only changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
server:
2+
port: 8081
3+
4+
spring:
5+
application:
6+
name: sc-gateway-server
7+
cloud:
8+
gateway:
9+
discovery:
10+
locator:
11+
enabled: true
12+
lowerCaseServiceId: true
13+
routes:
14+
- id: service-hi
15+
uri: lb://SERVICE-HI
16+
predicates:
17+
- Path=/demo/**
18+
filters:
19+
- StripPrefix=1
20+
- Elapsed=false
21+
22+
eureka:
23+
client:
24+
service-url:
25+
defaultZone: http://localhost:8761/eureka/
26+
27+
logging:
28+
level:
29+
org.springframework.cloud.gateway: debug
30+
31+
32+

sc-f-gateway-cloud/service-hi/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<parent>
1515
<groupId>com.forezp</groupId>
16-
<artifactId>sc-f-chapter1</artifactId>
16+
<artifactId>sc-f-gateway-cloud</artifactId>
1717
<version>0.0.1-SNAPSHOT</version>
1818
</parent>
1919

sc-f-gateway-cloud/service-hi/src/main/java/com/forezp/servicehi/ServiceHiApplication.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public String home(@RequestParam(value = "name", defaultValue = "forezp") String
2626
return "hi " + name + " ,i am from port:" + port;
2727
}
2828

29+
30+
// @RequestMapping("/demo/hi")
31+
// public String qsw(@RequestParam(value = "name", defaultValue = "forezp") String name) {
32+
// return "hi " + name + " ,i am from port:" + port;
33+
// }
2934
}
3035

3136

0 commit comments

Comments
 (0)