new foo controller - work in progress
This commit is contained in:
parent
f06b24bea2
commit
71c8dffe40
|
@ -39,6 +39,34 @@
|
|||
<scope>runtime</scope>
|
||||
</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 -->
|
||||
|
||||
<dependency>
|
||||
|
@ -80,7 +108,7 @@
|
|||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
|
@ -90,7 +118,7 @@
|
|||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
|
@ -143,17 +171,17 @@
|
|||
|
||||
<!-- persistence -->
|
||||
<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 -->
|
||||
<org.slf4j.version>1.7.5</org.slf4j.version>
|
||||
<logback.version>1.0.11</logback.version>
|
||||
<!-- marshalling -->
|
||||
|
||||
<jackson.version>2.3.0</jackson.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.0.2.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>15.0</guava.version>
|
||||
<guava.version>16.0-rc1</guava.version>
|
||||
<commons-lang3.version>3.1</commons-lang3.version>
|
||||
|
||||
<!-- testing -->
|
||||
|
@ -161,16 +189,20 @@
|
|||
<junit.version>4.11</junit.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>
|
||||
|
||||
<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-compiler-plugin.version>3.1</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.4</maven-war-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>
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
|
@ -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>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>3.18.0-GA</version>
|
||||
<version>3.18.1-GA</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
|
|
Loading…
Reference in New Issue