new foo controller - work in progress
This commit is contained in:
parent
f06b24bea2
commit
71c8dffe40
@ -39,6 +39,34 @@
|
|||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- marshalling -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>${jackson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
|
<artifactId>xstream</artifactId>
|
||||||
|
<version>1.4.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- util -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- test scoped -->
|
<!-- test scoped -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -143,17 +171,17 @@
|
|||||||
|
|
||||||
<!-- persistence -->
|
<!-- persistence -->
|
||||||
<hibernate.version>4.3.0.Final</hibernate.version>
|
<hibernate.version>4.3.0.Final</hibernate.version>
|
||||||
<mysql-connector-java.version>5.1.27</mysql-connector-java.version>
|
<mysql-connector-java.version>5.1.28</mysql-connector-java.version>
|
||||||
|
|
||||||
<!-- logging -->
|
<!-- marshalling -->
|
||||||
<org.slf4j.version>1.7.5</org.slf4j.version>
|
|
||||||
<logback.version>1.0.11</logback.version>
|
<jackson.version>2.3.0</jackson.version>
|
||||||
|
|
||||||
<!-- various -->
|
<!-- various -->
|
||||||
<hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
|
<hibernate-validator.version>5.0.2.Final</hibernate-validator.version>
|
||||||
|
|
||||||
<!-- util -->
|
<!-- util -->
|
||||||
<guava.version>15.0</guava.version>
|
<guava.version>16.0-rc1</guava.version>
|
||||||
<commons-lang3.version>3.1</commons-lang3.version>
|
<commons-lang3.version>3.1</commons-lang3.version>
|
||||||
|
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
@ -161,16 +189,20 @@
|
|||||||
<junit.version>4.11</junit.version>
|
<junit.version>4.11</junit.version>
|
||||||
<mockito.version>1.9.5</mockito.version>
|
<mockito.version>1.9.5</mockito.version>
|
||||||
|
|
||||||
<httpcore.version>4.3</httpcore.version>
|
<httpcore.version>4.3.1</httpcore.version>
|
||||||
<httpclient.version>4.3.1</httpclient.version>
|
<httpclient.version>4.3.1</httpclient.version>
|
||||||
|
|
||||||
<rest-assured.version>2.1.0</rest-assured.version>
|
<rest-assured.version>2.2.0</rest-assured.version>
|
||||||
|
|
||||||
|
<!-- logging -->
|
||||||
|
<org.slf4j.version>1.7.5</org.slf4j.version>
|
||||||
|
<logback.version>1.0.11</logback.version>
|
||||||
|
|
||||||
<!-- Maven plugins -->
|
<!-- Maven plugins -->
|
||||||
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
|
||||||
<maven-war-plugin.version>2.4</maven-war-plugin.version>
|
<maven-war-plugin.version>2.4</maven-war-plugin.version>
|
||||||
<maven-surefire-plugin.version>2.16</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.16</maven-surefire-plugin.version>
|
||||||
<cargo-maven2-plugin.version>1.4.5</cargo-maven2-plugin.version>
|
<cargo-maven2-plugin.version>1.4.6</cargo-maven2-plugin.version>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package org.baeldung.web.controller;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||||
|
import static org.apache.commons.lang3.RandomStringUtils.randomNumeric;
|
||||||
|
|
||||||
|
import org.baeldung.web.dto.Foo;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class FooController {
|
||||||
|
|
||||||
|
public FooController() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
// API
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = "/foos/{id}")
|
||||||
|
public @ResponseBody
|
||||||
|
Foo findById(@PathVariable final long id) {
|
||||||
|
return new Foo(Long.parseLong(randomNumeric(2)), randomAlphabetic(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
39
spring-rest/src/main/java/org/baeldung/web/dto/Foo.java
Normal file
39
spring-rest/src/main/java/org/baeldung/web/dto/Foo.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package org.baeldung.web.dto;
|
||||||
|
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
|
|
||||||
|
@XStreamAlias("Foo")
|
||||||
|
public class Foo {
|
||||||
|
private long id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Foo() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Foo(final long id, final String name) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// API
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(final long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -91,7 +91,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.javassist</groupId>
|
<groupId>org.javassist</groupId>
|
||||||
<artifactId>javassist</artifactId>
|
<artifactId>javassist</artifactId>
|
||||||
<version>3.18.0-GA</version>
|
<version>3.18.1-GA</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user