initial cleanup
This commit is contained in:
parent
359b9252fd
commit
49594e49e3
@ -22,15 +22,14 @@
|
|||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
@ -20,11 +20,6 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
|
||||||
<name>org.springframework.ide.eclipse.core.springbuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
@ -32,7 +27,6 @@
|
|||||||
</buildCommand>
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.springframework.ide.eclipse.core.springnature</nature>
|
|
||||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota
|
|||||||
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
|
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
@ -92,4 +92,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa
|
|||||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
org.eclipse.jdt.core.compiler.source=1.5
|
||||||
|
@ -1,43 +1,24 @@
|
|||||||
<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">
|
<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">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.baeldung</groupId>
|
<groupId>org.baeldung</groupId>
|
||||||
<artifactId>spring-rest</artifactId>
|
<artifactId>spring-rest</artifactId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>spring-rest</name>
|
<name>spring-rest</name>
|
||||||
<packaging>war</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- utils -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>spring-web</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>15.0</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-webmvc</artifactId>
|
|
||||||
<version>${org.springframework.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- web -->
|
<!-- web -->
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
|
||||||
<version>3.0.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>jstl</artifactId>
|
|
||||||
<version>1.2</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- test scoped -->
|
<!-- test scoped -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -136,7 +117,7 @@
|
|||||||
<hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
|
<hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
|
||||||
|
|
||||||
<!-- util -->
|
<!-- util -->
|
||||||
<guava.version>14.0.1</guava.version>
|
<guava.version>15.0</guava.version>
|
||||||
<commons-lang3.version>3.1</commons-lang3.version>
|
<commons-lang3.version>3.1</commons-lang3.version>
|
||||||
|
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package org.baeldung.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
||||||
|
|
||||||
@EnableWebMvc
|
|
||||||
@Configuration
|
|
||||||
@ComponentScan({ "org.baeldung.controller" })
|
|
||||||
public class MvcConfig {
|
|
||||||
|
|
||||||
public MvcConfig() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package org.baeldung.controller;
|
|
||||||
|
|
||||||
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.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class BarController {
|
|
||||||
|
|
||||||
public BarController() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
// API
|
|
||||||
|
|
||||||
// with @RequestParam
|
|
||||||
|
|
||||||
@RequestMapping(value = "/bars")
|
|
||||||
@ResponseBody
|
|
||||||
public String getBarBySimplePathWithRequestParam(@RequestParam("id") final long id) {
|
|
||||||
return "Get a specific Bar with id=" + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/bars", params = "id")
|
|
||||||
@ResponseBody
|
|
||||||
public String getBarBySimplePathWithExplicitRequestParam(@RequestParam("id") final long id) {
|
|
||||||
return "Get a specific Bar with id=" + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/bars", params = { "id", "second" })
|
|
||||||
@ResponseBody
|
|
||||||
public String getBarBySimplePathWithExplicitRequestParams(@RequestParam("id") final long id) {
|
|
||||||
return "Get a specific Bar with id=" + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// with @PathVariable
|
|
||||||
|
|
||||||
@RequestMapping(value = "/bars/{numericId:[\\d]+}")
|
|
||||||
@ResponseBody
|
|
||||||
public String getBarsBySimplePathWithPathVariable(@PathVariable final long numericId) {
|
|
||||||
return "Get a specific Bar with id=" + numericId;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
package org.baeldung.controller;
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
// by paths
|
|
||||||
|
|
||||||
@RequestMapping(value = "/foos")
|
|
||||||
@ResponseBody
|
|
||||||
public String getFoosBySimplePath() {
|
|
||||||
return "Simple Get some Foos";
|
|
||||||
}
|
|
||||||
|
|
||||||
// with @PathVariable
|
|
||||||
|
|
||||||
@RequestMapping(value = "/foos/{id}")
|
|
||||||
@ResponseBody
|
|
||||||
public String getFoosBySimplePathWithPathVariable(@PathVariable final long id) {
|
|
||||||
return "Get a specific Foo with id=" + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/foos/{fooid}/bar/{barid}")
|
|
||||||
@ResponseBody
|
|
||||||
public String getFoosBySimplePathWithPathVariables(@PathVariable final long fooid, @PathVariable final long barid) {
|
|
||||||
return "Get a specific Bar with id=" + barid + " from a Foo with id=" + fooid;
|
|
||||||
}
|
|
||||||
|
|
||||||
// other HTTP verbs
|
|
||||||
|
|
||||||
@RequestMapping(value = "/foos", method = RequestMethod.POST)
|
|
||||||
@ResponseBody
|
|
||||||
public String postFoos() {
|
|
||||||
return "Post some Foos";
|
|
||||||
}
|
|
||||||
|
|
||||||
// with headers
|
|
||||||
|
|
||||||
@RequestMapping(value = "/foos", headers = "key=val")
|
|
||||||
@ResponseBody
|
|
||||||
public String getFoosWithHeader() {
|
|
||||||
return "Get some Foos with Header";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/foos", headers = { "key1=val1", "key2=val2" })
|
|
||||||
@ResponseBody
|
|
||||||
public String getFoosWithHeaders() {
|
|
||||||
return "Get some Foos with Header";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/foos", produces = { "application/json", "application/xml" })
|
|
||||||
@ResponseBody
|
|
||||||
public String getFoosAsJsonFromREST() {
|
|
||||||
return "Get some Foos with Header Exact";
|
|
||||||
}
|
|
||||||
|
|
||||||
// advanced - multiple mappings
|
|
||||||
|
|
||||||
@RequestMapping(value = { "/advanced/bars", "/advanced/foos" })
|
|
||||||
@ResponseBody
|
|
||||||
public String getFoosOrBarsByPath() {
|
|
||||||
return "Advanced - Get some Foos or Bars";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "*")
|
|
||||||
@ResponseBody
|
|
||||||
public String getFallback() {
|
|
||||||
return "Fallback for GET Requests";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "*", method = { RequestMethod.GET, RequestMethod.POST })
|
|
||||||
@ResponseBody
|
|
||||||
public String allFallback() {
|
|
||||||
return "Fallback for All Requests";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/foos/multiple", method = { RequestMethod.PUT, RequestMethod.POST })
|
|
||||||
@ResponseBody
|
|
||||||
public String putAndPostFoos() {
|
|
||||||
return "Advanced - PUT and POST within single method";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user