Skip to content

Commit 377c71e

Browse files
committed
add zuul module
1 parent 9de8a4a commit 377c71e

30 files changed

Lines changed: 975 additions & 0 deletions

File tree

‎spring-zuul/.project‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>spring-zuul</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.m2e.core.maven2Builder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
16+
</natures>
17+
</projectDescription>

‎spring-zuul/pom.xml‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>org.baeldung</groupId>
4+
<artifactId>spring-zuul</artifactId>
5+
<version>1.0.0-SNAPSHOT</version>
6+
7+
<name>spring-zuul</name>
8+
<packaging>pom</packaging>
9+
10+
<parent>
11+
<groupId>org.springframework.boot</groupId>
12+
<artifactId>spring-boot-starter-parent</artifactId>
13+
<version>1.3.1.RELEASE</version>
14+
</parent>
15+
16+
<modules>
17+
<module>spring-zuul-foos-resource</module>
18+
<module>spring-zuul-users-resource</module>
19+
<module>spring-zuul-ui</module>
20+
</modules>
21+
22+
<build>
23+
<finalName>spring-zuul</finalName>
24+
<pluginManagement>
25+
<plugins>
26+
27+
<plugin>
28+
<groupId>org.apache.maven.plugins</groupId>
29+
<artifactId>maven-compiler-plugin</artifactId>
30+
<version>${maven-compiler-plugin.version}</version>
31+
<configuration>
32+
<source>1.8</source>
33+
<target>1.8</target>
34+
</configuration>
35+
</plugin>
36+
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-war-plugin</artifactId>
40+
<version>${maven-war-plugin.version}</version>
41+
<configuration>
42+
<failOnMissingWebXml>false</failOnMissingWebXml>
43+
</configuration>
44+
</plugin>
45+
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-surefire-plugin</artifactId>
49+
<version>${maven-surefire-plugin.version}</version>
50+
<configuration>
51+
<testFailureIgnore>true</testFailureIgnore>
52+
<excludes>
53+
<exclude>**/*IntegrationTest.java</exclude>
54+
<exclude>**/*LiveTest.java</exclude>
55+
</excludes>
56+
<systemPropertyVariables>
57+
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
58+
</systemPropertyVariables>
59+
</configuration>
60+
</plugin>
61+
62+
</plugins>
63+
</pluginManagement>
64+
</build>
65+
66+
67+
<properties>
68+
<!-- Spring -->
69+
<org.springframework.version>4.2.2.RELEASE</org.springframework.version>
70+
<org.springframework.security.version>4.0.3.RELEASE</org.springframework.security.version>
71+
72+
<!-- marshalling -->
73+
74+
<jackson.version>2.5.1</jackson.version>
75+
76+
<!-- logging -->
77+
<org.slf4j.version>1.7.12</org.slf4j.version>
78+
<logback.version>1.1.3</logback.version>
79+
80+
<!-- util -->
81+
<guava.version>18.0</guava.version>
82+
<commons-lang3.version>3.3.2</commons-lang3.version>
83+
84+
<!-- testing -->
85+
<org.hamcrest.version>1.3</org.hamcrest.version>
86+
<junit.version>4.11</junit.version>
87+
<mockito.version>1.10.19</mockito.version>
88+
89+
<httpcore.version>4.4</httpcore.version>
90+
<httpclient.version>4.4</httpclient.version>
91+
92+
<rest-assured.version>2.4.0</rest-assured.version>
93+
94+
<!-- Maven plugins -->
95+
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
96+
<maven-war-plugin.version>2.6</maven-war-plugin.version>
97+
<maven-surefire-plugin.version>2.19</maven-surefire-plugin.version>
98+
<cargo-maven2-plugin.version>1.4.16</cargo-maven2-plugin.version>
99+
100+
</properties>
101+
102+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="optional" value="true"/>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
26+
<attributes>
27+
<attribute name="maven.pomderived" value="true"/>
28+
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
29+
</attributes>
30+
</classpathentry>
31+
<classpathentry kind="output" path="target/classes"/>
32+
</classpath>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>spring-zuul-foos-resource</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.jdt.core.javabuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.m2e.core.maven2Builder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
<buildCommand>
29+
<name>org.springframework.ide.eclipse.core.springbuilder</name>
30+
<arguments>
31+
</arguments>
32+
</buildCommand>
33+
<buildCommand>
34+
<name>org.eclipse.wst.validation.validationbuilder</name>
35+
<arguments>
36+
</arguments>
37+
</buildCommand>
38+
</buildSpec>
39+
<natures>
40+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
41+
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
42+
<nature>org.springframework.ide.eclipse.core.springnature</nature>
43+
<nature>org.eclipse.jdt.core.javanature</nature>
44+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
45+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
46+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
47+
</natures>
48+
</projectDescription>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>spring-zuul-foos-resource</artifactId>
5+
<name>spring-zuul-foos-resource</name>
6+
<packaging>war</packaging>
7+
8+
<parent>
9+
<groupId>org.baeldung</groupId>
10+
<artifactId>spring-zuul</artifactId>
11+
<version>1.0.0-SNAPSHOT</version>
12+
</parent>
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.apache.commons</groupId>
22+
<artifactId>commons-lang3</artifactId>
23+
<version>${commons-lang3.version}</version>
24+
</dependency>
25+
26+
</dependencies>
27+
28+
<build>
29+
<finalName>spring-zuul-foos-resource</finalName>
30+
<resources>
31+
<resource>
32+
<directory>src/main/resources</directory>
33+
<filtering>true</filtering>
34+
</resource>
35+
</resources>
36+
</build>
37+
38+
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.baeldung.config;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.context.web.SpringBootServletInitializer;
6+
7+
@SpringBootApplication
8+
public class ResourceServerApplication extends SpringBootServletInitializer {
9+
10+
public static void main(String[] args) {
11+
SpringApplication.run(ResourceServerApplication.class, args);
12+
}
13+
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.baeldung.config;
2+
3+
import org.springframework.context.annotation.ComponentScan;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
6+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
7+
8+
@Configuration
9+
@EnableWebMvc
10+
@ComponentScan({ "org.baeldung.web.controller" })
11+
public class ResourceServerWebConfig extends WebMvcConfigurerAdapter {
12+
13+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.baeldung.web.controller;
2+
3+
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
4+
import static org.apache.commons.lang3.RandomStringUtils.randomNumeric;
5+
6+
import javax.servlet.http.HttpServletRequest;
7+
import javax.servlet.http.HttpServletResponse;
8+
9+
import org.baeldung.web.dto.Foo;
10+
import org.springframework.stereotype.Controller;
11+
import org.springframework.web.bind.annotation.PathVariable;
12+
import org.springframework.web.bind.annotation.RequestMapping;
13+
import org.springframework.web.bind.annotation.RequestMethod;
14+
import org.springframework.web.bind.annotation.ResponseBody;
15+
16+
@Controller
17+
public class FooController {
18+
19+
public FooController() {
20+
super();
21+
}
22+
23+
// API - read
24+
@RequestMapping(method = RequestMethod.GET, value = "/foos/{id}")
25+
@ResponseBody
26+
public Foo findById(@PathVariable final long id, HttpServletRequest req, HttpServletResponse res) {
27+
// System.out.println(req.getHeaderNames());
28+
// System.out.println("------" + req.getHeader("Test"));
29+
if (req.getHeader("Test") != null) {
30+
res.addHeader("Test", req.getHeader("Test"));
31+
}
32+
return new Foo(Long.parseLong(randomNumeric(2)), randomAlphabetic(4));
33+
}
34+
35+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.baeldung.web.dto;
2+
3+
public class Foo {
4+
private long id;
5+
private String name;
6+
7+
public Foo() {
8+
super();
9+
}
10+
11+
public Foo(final long id, final String name) {
12+
super();
13+
14+
this.id = id;
15+
this.name = name;
16+
}
17+
18+
//
19+
20+
public long getId() {
21+
return id;
22+
}
23+
24+
public void setId(final long id) {
25+
this.id = id;
26+
}
27+
28+
public String getName() {
29+
return name;
30+
}
31+
32+
public void setName(final String name) {
33+
this.name = name;
34+
}
35+
36+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
server.contextPath=/spring-zuul-foos-resource
2+
server.port=8081

0 commit comments

Comments
 (0)