Skip to content

Commit 63a696c

Browse files
committed
Zuul Proxy Sample Application
1 parent deb37c1 commit 63a696c

12 files changed

Lines changed: 409 additions & 0 deletions

File tree

zuul/customer-service/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>zuul</artifactId>
7+
<groupId>com.fd</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>customer-service</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.springframework.boot</groupId>
17+
<artifactId>spring-boot-starter-web</artifactId>
18+
</dependency>
19+
20+
<dependency>
21+
<groupId>org.springframework.cloud</groupId>
22+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
23+
</dependency>
24+
</dependencies>
25+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.fd.sample.customer;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6+
7+
/**
8+
* @author furkand
9+
* 10/8/2018 9:58 AM
10+
*/
11+
@EnableDiscoveryClient
12+
@SpringBootApplication
13+
public class App {
14+
15+
public static void main(String[] args) {
16+
SpringApplication.run(App.class);
17+
}
18+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.fd.sample.customer.controller;
2+
3+
import com.fd.sample.customer.model.Customer;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.RestController;
7+
8+
import java.time.LocalDate;
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
/**
13+
* @author furkand
14+
* 10/8/2018 9:59 AM
15+
*/
16+
@RestController
17+
@RequestMapping("/api/customers")
18+
public class CustomerController {
19+
20+
@GetMapping
21+
public List<Customer> customerList() {
22+
Customer c1 = Customer.builder()
23+
.id("1").name("john doe").company("acme").birthdate(LocalDate.now().minusYears(28)).build();
24+
Customer c2 = Customer.builder()
25+
.id("2").name("jane doe").company("acme").birthdate(LocalDate.now().minusYears(24)).build();
26+
List<Customer> result = new ArrayList<>();
27+
result.add(c1);
28+
result.add(c2);
29+
return result;
30+
}
31+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.fd.sample.customer.model;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
import java.time.LocalDate;
9+
10+
/**
11+
* @author furkand
12+
* 10/8/2018 10:00 AM
13+
*/
14+
@Data
15+
@Builder
16+
@NoArgsConstructor
17+
@AllArgsConstructor
18+
public class Customer {
19+
20+
private String id;
21+
private String name;
22+
private String company;
23+
private LocalDate birthdate;
24+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
server:
2+
port: 8090
3+
4+
spring:
5+
application:
6+
name: customer-service
7+
8+
eureka:
9+
client:
10+
serviceUrl:
11+
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
12+
instance:
13+
preferIpAddress: true
14+
15+
logging:
16+
level:
17+
ROOT: INFO
18+
org.spring.framework: ERROR
19+
com.fd: TRACE
20+
pattern:
21+
console: "%-5level %d{yyyy-MM-dd HH:mm:ss} - %msg%n"

zuul/eureka-server/pom.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>zuul</artifactId>
7+
<groupId>com.fd</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>eureka-server</artifactId>
13+
14+
<properties>
15+
<jaxb.version>2.3.1</jaxb.version>
16+
<javax.activation.version>1.1.1</javax.activation.version>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.springframework.cloud</groupId>
22+
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>javax.activation</groupId>
27+
<artifactId>activation</artifactId>
28+
<version>${javax.activation.version}</version>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>org.glassfish.jaxb</groupId>
33+
<artifactId>jaxb-runtime</artifactId>
34+
<version>${jaxb.version}</version>
35+
</dependency>
36+
</dependencies>
37+
38+
</project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.fd.eureka.server;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6+
7+
/**
8+
* @author furkand
9+
* 10/8/2018 10:32 AM
10+
*/
11+
@EnableEurekaServer
12+
@SpringBootApplication
13+
public class App {
14+
15+
public static void main(String[] args) {
16+
SpringApplication.run(App.class, args);
17+
}
18+
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
server:
2+
port: 8761
3+
4+
eureka:
5+
client:
6+
register-with-eureka: false
7+
fetch-registry: false
8+
9+
logging:
10+
level:
11+
com:
12+
netflix:
13+
eureka: OFF
14+
discovery: OFF

zuul/pom.xml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.fd</groupId>
8+
<artifactId>zuul</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<modules>
11+
<module>customer-service</module>
12+
<module>zuul-proxy</module>
13+
<module>eureka-server</module>
14+
</modules>
15+
<packaging>pom</packaging>
16+
17+
<properties>
18+
<java-version>1.8</java-version>
19+
<maven.compiler.source>1.8</maven.compiler.source>
20+
<maven.compiler.target>1.8</maven.compiler.target>
21+
22+
<spring.boot.version>2.0.5.RELEASE</spring.boot.version>
23+
<spring.cloud.starter.hystrix.version>1.4.5.RELEASE</spring.cloud.starter.hystrix.version>
24+
<hamcrest-version>1.3</hamcrest-version>
25+
<lombok-version>1.18.2</lombok-version>
26+
<mapstruct.version>1.2.0.Final</mapstruct.version>
27+
<hibernate.jpamodelgen-version>5.3.2.Final</hibernate.jpamodelgen-version>
28+
<jaxb.version>2.3.0</jaxb.version>
29+
30+
<maven.plugin.compiler.version>3.7.0</maven.plugin.compiler.version>
31+
<maven.plugin.build-helper.version>3.0.0</maven.plugin.build-helper.version>
32+
<maven.plugin.processor.version>3.2.0</maven.plugin.processor.version>
33+
34+
</properties>
35+
36+
<dependencyManagement>
37+
<dependencies>
38+
<dependency>
39+
<groupId>org.springframework.cloud</groupId>
40+
<artifactId>spring-cloud-dependencies</artifactId>
41+
<version>Finchley.RELEASE</version>
42+
<type>pom</type>
43+
<scope>import</scope>
44+
</dependency>
45+
46+
<dependency>
47+
<groupId>org.springframework.boot</groupId>
48+
<artifactId>spring-boot-starter-parent</artifactId>
49+
<version>${spring.boot.version}</version>
50+
<type>pom</type>
51+
<scope>import</scope>
52+
</dependency>
53+
54+
</dependencies>
55+
</dependencyManagement>
56+
57+
<dependencies>
58+
<dependency>
59+
<groupId>org.projectlombok</groupId>
60+
<artifactId>lombok</artifactId>
61+
<version>${lombok-version}</version>
62+
</dependency>
63+
64+
<dependency>
65+
<groupId>org.hamcrest</groupId>
66+
<artifactId>hamcrest-all</artifactId>
67+
<version>${hamcrest-version}</version>
68+
<scope>test</scope>
69+
</dependency>
70+
71+
<dependency>
72+
<groupId>org.apache.logging.log4j</groupId>
73+
<artifactId>log4j-core</artifactId>
74+
</dependency>
75+
76+
<dependency>
77+
<groupId>org.apache.logging.log4j</groupId>
78+
<artifactId>log4j-slf4j-impl</artifactId>
79+
</dependency>
80+
</dependencies>
81+
82+
<build>
83+
<plugins>
84+
<!-- MAVEN COMPILER PLUGIN -->
85+
<plugin>
86+
<groupId>org.apache.maven.plugins</groupId>
87+
<artifactId>maven-compiler-plugin</artifactId>
88+
<version>${maven.plugin.compiler.version}</version>
89+
<configuration>
90+
<source>${java-version}</source>
91+
<target>${java-version}</target>
92+
<encoding>UTF-8</encoding>
93+
94+
<annotationProcessorPaths>
95+
<path>
96+
<groupId>org.mapstruct</groupId>
97+
<artifactId>mapstruct-processor</artifactId>
98+
<version>${mapstruct.version}</version>
99+
</path>
100+
<path>
101+
<groupId>org.projectlombok</groupId>
102+
<artifactId>lombok</artifactId>
103+
<version>${lombok-version}</version>
104+
</path>
105+
</annotationProcessorPaths>
106+
</configuration>
107+
</plugin>
108+
109+
<!-- MAVEN ADD GENERATED-SOURCES TO CLASSPATH -->
110+
<plugin>
111+
<groupId>org.codehaus.mojo</groupId>
112+
<artifactId>build-helper-maven-plugin</artifactId>
113+
<version>${maven.plugin.build-helper.version}</version>
114+
<executions>
115+
<execution>
116+
<phase>generate-sources</phase>
117+
<goals>
118+
<goal>add-source</goal>
119+
</goals>
120+
<configuration>
121+
<sources>
122+
<source>target/generated-sources/annotations</source>
123+
</sources>
124+
</configuration>
125+
</execution>
126+
</executions>
127+
</plugin>
128+
129+
<plugin>
130+
<groupId>org.springframework.boot</groupId>
131+
<artifactId>spring-boot-maven-plugin</artifactId>
132+
<version>${spring.boot.version}</version>
133+
</plugin>
134+
</plugins>
135+
</build>
136+
137+
</project>

zuul/zuul-proxy/pom.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>zuul</artifactId>
7+
<groupId>com.fd</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>zuul-proxy</artifactId>
13+
14+
<properties>
15+
<spring-cloud-starter-eureka.version>1.4.5.RELEASE</spring-cloud-starter-eureka.version>
16+
<spring-cloud-starter-zuul.version>1.4.5.RELEASE</spring-cloud-starter-zuul.version>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.springframework.cloud</groupId>
22+
<artifactId>spring-cloud-starter-eureka</artifactId>
23+
<version>${spring-cloud-starter-eureka.version}</version>
24+
</dependency>
25+
26+
<dependency>
27+
<groupId>org.springframework.cloud</groupId>
28+
<artifactId>spring-cloud-starter-zuul</artifactId>
29+
<version>${spring-cloud-starter-zuul.version}</version>
30+
</dependency>
31+
32+
</dependencies>
33+
34+
</project>

0 commit comments

Comments
 (0)