Skip to content

Commit 71c8dff

Browse files
author
eugenp
committed
new foo controller - work in progress
1 parent f06b24b commit 71c8dff

File tree

4 files changed

+111
-12
lines changed

4 files changed

+111
-12
lines changed

spring-rest/pom.xml

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,34 @@
3939
<scope>runtime</scope>
4040
</dependency>
4141

42+
<!-- marshalling -->
43+
44+
<dependency>
45+
<groupId>com.fasterxml.jackson.core</groupId>
46+
<artifactId>jackson-databind</artifactId>
47+
<version>${jackson.version}</version>
48+
</dependency>
49+
50+
<dependency>
51+
<groupId>com.thoughtworks.xstream</groupId>
52+
<artifactId>xstream</artifactId>
53+
<version>1.4.6</version>
54+
</dependency>
55+
56+
<!-- util -->
57+
58+
<dependency>
59+
<groupId>com.google.guava</groupId>
60+
<artifactId>guava</artifactId>
61+
<version>${guava.version}</version>
62+
</dependency>
63+
64+
<dependency>
65+
<groupId>org.apache.commons</groupId>
66+
<artifactId>commons-lang3</artifactId>
67+
<version>3.2.1</version>
68+
</dependency>
69+
4270
<!-- test scoped -->
4371

4472
<dependency>
@@ -80,7 +108,7 @@
80108
</resources>
81109

82110
<plugins>
83-
111+
84112
<plugin>
85113
<groupId>org.apache.maven.plugins</groupId>
86114
<artifactId>maven-compiler-plugin</artifactId>
@@ -90,7 +118,7 @@
90118
<target>1.7</target>
91119
</configuration>
92120
</plugin>
93-
121+
94122
<plugin>
95123
<groupId>org.apache.maven.plugins</groupId>
96124
<artifactId>maven-war-plugin</artifactId>
@@ -143,34 +171,38 @@
143171

144172
<!-- persistence -->
145173
<hibernate.version>4.3.0.Final</hibernate.version>
146-
<mysql-connector-java.version>5.1.27</mysql-connector-java.version>
174+
<mysql-connector-java.version>5.1.28</mysql-connector-java.version>
147175

148-
<!-- logging -->
149-
<org.slf4j.version>1.7.5</org.slf4j.version>
150-
<logback.version>1.0.11</logback.version>
176+
<!-- marshalling -->
177+
178+
<jackson.version>2.3.0</jackson.version>
151179

152180
<!-- various -->
153-
<hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
181+
<hibernate-validator.version>5.0.2.Final</hibernate-validator.version>
154182

155183
<!-- util -->
156-
<guava.version>15.0</guava.version>
184+
<guava.version>16.0-rc1</guava.version>
157185
<commons-lang3.version>3.1</commons-lang3.version>
158186

159187
<!-- testing -->
160188
<org.hamcrest.version>1.3</org.hamcrest.version>
161189
<junit.version>4.11</junit.version>
162190
<mockito.version>1.9.5</mockito.version>
163191

164-
<httpcore.version>4.3</httpcore.version>
192+
<httpcore.version>4.3.1</httpcore.version>
165193
<httpclient.version>4.3.1</httpclient.version>
166194

167-
<rest-assured.version>2.1.0</rest-assured.version>
195+
<rest-assured.version>2.2.0</rest-assured.version>
196+
197+
<!-- logging -->
198+
<org.slf4j.version>1.7.5</org.slf4j.version>
199+
<logback.version>1.0.11</logback.version>
168200

169201
<!-- Maven plugins -->
170202
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
171203
<maven-war-plugin.version>2.4</maven-war-plugin.version>
172204
<maven-surefire-plugin.version>2.16</maven-surefire-plugin.version>
173-
<cargo-maven2-plugin.version>1.4.5</cargo-maven2-plugin.version>
205+
<cargo-maven2-plugin.version>1.4.6</cargo-maven2-plugin.version>
174206

175207
</properties>
176208

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 org.baeldung.web.dto.Foo;
7+
import org.springframework.stereotype.Controller;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.RequestMapping;
10+
import org.springframework.web.bind.annotation.RequestMethod;
11+
import org.springframework.web.bind.annotation.ResponseBody;
12+
13+
@Controller
14+
public class FooController {
15+
16+
public FooController() {
17+
super();
18+
}
19+
20+
// API
21+
22+
@RequestMapping(method = RequestMethod.GET, value = "/foos/{id}")
23+
public @ResponseBody
24+
Foo findById(@PathVariable final long id) {
25+
return new Foo(Long.parseLong(randomNumeric(2)), randomAlphabetic(4));
26+
}
27+
28+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.baeldung.web.dto;
2+
3+
import com.thoughtworks.xstream.annotations.XStreamAlias;
4+
5+
@XStreamAlias("Foo")
6+
public class Foo {
7+
private long id;
8+
private String name;
9+
10+
public Foo() {
11+
super();
12+
}
13+
14+
public Foo(final long id, final String name) {
15+
super();
16+
17+
this.id = id;
18+
this.name = name;
19+
}
20+
21+
// API
22+
23+
public long getId() {
24+
return id;
25+
}
26+
27+
public void setId(final long id) {
28+
this.id = id;
29+
}
30+
31+
public String getName() {
32+
return name;
33+
}
34+
35+
public void setName(final String name) {
36+
this.name = name;
37+
}
38+
39+
}

spring-security-rest-full/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<dependency>
9292
<groupId>org.javassist</groupId>
9393
<artifactId>javassist</artifactId>
94-
<version>3.18.0-GA</version>
94+
<version>3.18.1-GA</version>
9595
</dependency>
9696
<dependency>
9797
<groupId>mysql</groupId>

0 commit comments

Comments
 (0)