diff --git a/spring-mvc-basics/README.md b/spring-mvc-basics/README.md
index 63d046de2d..aa1fffdf42 100644
--- a/spring-mvc-basics/README.md
+++ b/spring-mvc-basics/README.md
@@ -7,3 +7,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles:
- [Spring MVC Tutorial](https://www.baeldung.com/spring-mvc-tutorial)
+- [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller)
diff --git a/spring-mvc-basics/pom.xml b/spring-mvc-basics/pom.xml
index 8217421948..cb9f1be9eb 100644
--- a/spring-mvc-basics/pom.xml
+++ b/spring-mvc-basics/pom.xml
@@ -36,6 +36,13 @@
jstl
${jstl.version}
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
org.springframework
@@ -43,6 +50,12 @@
${spring.version}
test
+
+ com.jayway.jsonpath
+ json-path
+ test
+ ${jayway.json-path.version}
+
@@ -58,6 +71,7 @@
4.0.1
2.3.3
+ 2.4.0
diff --git a/spring-mvc-basics/src/main/java/com/baeldung/model/Book.java b/spring-mvc-basics/src/main/java/com/baeldung/model/Book.java
new file mode 100644
index 0000000000..bdfa1d835a
--- /dev/null
+++ b/spring-mvc-basics/src/main/java/com/baeldung/model/Book.java
@@ -0,0 +1,42 @@
+package com.baeldung.model;
+
+public class Book {
+
+ private int id;
+ private String author;
+ private String title;
+
+ public Book() {
+ }
+
+ public Book(int id, String author, String title) {
+ this.id = id;
+ this.author = author;
+ this.title = title;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+}
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/SimpleBookController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookController.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/SimpleBookController.java
rename to spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookController.java
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java
rename to spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java
diff --git a/spring-mvc-basics/src/test/java/com/baeldung/SpringContextIntegrationTest.java b/spring-mvc-basics/src/test/java/com/baeldung/SpringContextIntegrationTest.java
index d8cf4cfc0d..511e56aeab 100644
--- a/spring-mvc-basics/src/test/java/com/baeldung/SpringContextIntegrationTest.java
+++ b/spring-mvc-basics/src/test/java/com/baeldung/SpringContextIntegrationTest.java
@@ -1,6 +1,6 @@
package com.baeldung;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java b/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java
similarity index 90%
rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java
rename to spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java
index 23be3a1655..87d70c2d29 100644
--- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java
+++ b/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java
@@ -5,19 +5,17 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import com.baeldung.web.controller.SimpleBookController;
-
public class SimpleBookControllerIntegrationTest {
private MockMvc mockMvc;
private static final String CONTENT_TYPE = "application/json;charset=UTF-8";
- @Before
+ @BeforeEach
public void setup() {
this.mockMvc = MockMvcBuilders.standaloneSetup(new SimpleBookController()).build();
}
diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java b/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java
similarity index 85%
rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java
rename to spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java
index c5bd53f1a7..294943f2e2 100644
--- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java
+++ b/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java
@@ -5,27 +5,25 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import com.baeldung.web.controller.SimpleBookController;
-
public class SimpleBookRestControllerIntegrationTest {
private MockMvc mockMvc;
private static final String CONTENT_TYPE = "application/json;charset=UTF-8";
- @Before
+ @BeforeEach
public void setup() {
- this.mockMvc = MockMvcBuilders.standaloneSetup(new SimpleBookController()).build();
+ this.mockMvc = MockMvcBuilders.standaloneSetup(new SimpleBookRestController()).build();
}
@Test
public void givenBookId_whenMockMVC_thenVerifyResponse() throws Exception {
this.mockMvc
- .perform(get("/books/42"))
+ .perform(get("/books-rest/42"))
.andExpect(status().isOk())
.andExpect(content().contentType(CONTENT_TYPE))
.andExpect(jsonPath("$.id").value(42));
diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md
index 2c0f594bd2..e39ddd8af7 100644
--- a/spring-mvc-java/README.md
+++ b/spring-mvc-java/README.md
@@ -24,7 +24,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [web.xml vs Initializer with Spring](http://www.baeldung.com/spring-xml-vs-java-config)
- [The HttpMediaTypeNotAcceptableException in Spring MVC](http://www.baeldung.com/spring-httpmediatypenotacceptable)
- [Spring MVC and the @ModelAttribute Annotation](http://www.baeldung.com/spring-mvc-and-the-modelattribute-annotation)
-- [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller)
- [Spring MVC @PathVariable with a dot (.) gets truncated](http://www.baeldung.com/spring-mvc-pathvariable-dot)
- [A Quick Example of Spring Websockets’ @SendToUser Annotation](http://www.baeldung.com/spring-websockets-sendtouser)
- [Using Spring ResponseEntity to Manipulate the HTTP Response](http://www.baeldung.com/spring-response-entity)