diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml
index 997b99ffdf..3eb5bc9bd6 100644
--- a/spring-security-rest-full/pom.xml
+++ b/spring-security-rest-full/pom.xml
@@ -159,6 +159,13 @@
+
+ org.springframework
+ spring-test
+ ${org.springframework.version}
+ test
+
+
junit
junit-dep
diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java
index 7a9889ae46..5e05db1056 100644
--- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java
+++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/FooController.java
@@ -1,6 +1,5 @@
package org.baeldung.web.controller;
-import java.net.URI;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
@@ -10,7 +9,6 @@ import org.baeldung.persistence.model.Foo;
import org.baeldung.persistence.service.IFooService;
import org.baeldung.web.exception.MyResourceNotFoundException;
import org.baeldung.web.hateoas.PaginatedResultsRetrievedEvent;
-import org.baeldung.web.util.LinkUtil;
import org.baeldung.web.util.ResourceCreated;
import org.baeldung.web.util.RestPreconditions;
import org.baeldung.web.util.SingleResourceRetrieved;
@@ -27,7 +25,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.util.UriComponentsBuilder;
-import org.springframework.web.util.UriTemplate;
import com.google.common.base.Preconditions;
@@ -77,21 +74,9 @@ public class FooController {
return resultPage.getContent();
}
- // discover
-
- @RequestMapping(value = "admin", method = RequestMethod.GET)
- @ResponseStatus(value = HttpStatus.NO_CONTENT)
- public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) {
- final String rootUri = request.getRequestURL().toString();
-
- final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo");
- final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection");
- response.addHeader("Link", linkToFoo);
- }
-
// write
- @RequestMapping(value = "admin/foo", method = RequestMethod.POST)
+ @RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public void create(@RequestBody final Foo resource, final HttpServletRequest request, final HttpServletResponse response) {
Preconditions.checkNotNull(resource);
diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java
new file mode 100644
index 0000000000..0f35a29338
--- /dev/null
+++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java
@@ -0,0 +1,37 @@
+package org.baeldung.web.controller;
+
+import java.net.URI;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.baeldung.web.util.LinkUtil;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.util.UriTemplate;
+
+@Controller
+public class RootController {
+
+ public RootController() {
+ super();
+ }
+
+ // API
+
+ // discover
+
+ @RequestMapping(value = "admin", method = RequestMethod.GET)
+ @ResponseStatus(value = HttpStatus.NO_CONTENT)
+ public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) {
+ final String rootUri = request.getRequestURL().toString();
+
+ final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo");
+ final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection");
+ response.addHeader("Link", linkToFoo);
+ }
+
+}
diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java
index be2d4331c1..a465a82d75 100644
--- a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java
+++ b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java
@@ -28,8 +28,14 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH
// 400
- @ExceptionHandler({ ConstraintViolationException.class, DataIntegrityViolationException.class })
- public ResponseEntity