From 108522e190261b1795fd55b9beb3c94b81af84fd Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 6 Jan 2021 11:16:55 +0100 Subject: [PATCH] JAVA-3541: Move spring-5-mvc into spring-web-modules --- pom.xml | 2 - spring-web-modules/pom.xml | 1 + .../spring-5-mvc}/.gitignore | 0 .../spring-5-mvc}/README.md | 0 .../spring-5-mvc}/pom.xml | 3 +- .../src/main/java/com/baeldung/Constants.java | 0 .../java/com/baeldung/Spring5Application.java | 0 .../com/baeldung/html/HtmlApplication.java | 0 .../com/baeldung/html/HtmlController.java | 0 .../java/com/baeldung/idc/Application.java | 0 .../src/main/java/com/baeldung/idc/Book.java | 0 .../java/com/baeldung/idc/BookController.java | 0 .../java/com/baeldung/idc/BookOperations.java | 0 .../java/com/baeldung/idc/BookRepository.java | 0 .../src/main/java/com/baeldung/model/Foo.java | 0 .../baeldung/persistence/DataSetupBean.java | 0 .../baeldung/persistence/FooRepository.java | 0 .../java/com/baeldung/web/FooController.java | 130 +++++++++--------- .../web/ResponseBodyEmitterController.java | 0 .../baeldung/web/SseEmitterController.java | 0 .../web/StreamingResponseBodyController.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/logback.xml | 0 .../src/main/webapp/WEB-INF/jsp/index.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/test/java/com/baeldung/LiveTest.java | 0 .../Spring5ApplicationIntegrationTest.java | 0 .../com/baeldung/html/HtmlControllerTest.java | 0 28 files changed, 67 insertions(+), 69 deletions(-) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/.gitignore (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/README.md (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/pom.xml (97%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/Constants.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/Spring5Application.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/html/HtmlApplication.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/html/HtmlController.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/idc/Application.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/idc/Book.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/idc/BookController.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/idc/BookOperations.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/idc/BookRepository.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/model/Foo.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/persistence/DataSetupBean.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/persistence/FooRepository.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/web/FooController.java (97%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/web/SseEmitterController.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/web/StreamingResponseBodyController.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/resources/application.properties (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/resources/logback.xml (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/webapp/WEB-INF/jsp/index.jsp (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/test/java/com/baeldung/LiveTest.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/test/java/com/baeldung/html/HtmlControllerTest.java (100%) diff --git a/pom.xml b/pom.xml index 464134b572..3eca22c173 100644 --- a/pom.xml +++ b/pom.xml @@ -601,7 +601,6 @@ spring-5 spring-5-data-reactive - spring-5-mvc spring-5-reactive spring-5-reactive-2 spring-5-reactive-client @@ -1055,7 +1054,6 @@ spring-5 spring-5-data-reactive - spring-5-mvc spring-5-reactive spring-5-reactive-2 spring-5-reactive-client diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index e00ae3e899..cc2ffcf762 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -14,6 +14,7 @@ + spring-5-mvc spring-mvc-basics spring-mvc-basics-2 spring-mvc-basics-3 diff --git a/spring-5-mvc/.gitignore b/spring-web-modules/spring-5-mvc/.gitignore similarity index 100% rename from spring-5-mvc/.gitignore rename to spring-web-modules/spring-5-mvc/.gitignore diff --git a/spring-5-mvc/README.md b/spring-web-modules/spring-5-mvc/README.md similarity index 100% rename from spring-5-mvc/README.md rename to spring-web-modules/spring-5-mvc/README.md diff --git a/spring-5-mvc/pom.xml b/spring-web-modules/spring-5-mvc/pom.xml similarity index 97% rename from spring-5-mvc/pom.xml rename to spring-web-modules/spring-5-mvc/pom.xml index 39fcd22824..ddcce8207b 100644 --- a/spring-5-mvc/pom.xml +++ b/spring-web-modules/spring-5-mvc/pom.xml @@ -12,8 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 - + ../../parent-boot-2 diff --git a/spring-5-mvc/src/main/java/com/baeldung/Constants.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/Constants.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/Constants.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/Constants.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/Spring5Application.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/Spring5Application.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/Spring5Application.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/Spring5Application.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/html/HtmlApplication.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/html/HtmlApplication.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/html/HtmlApplication.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/html/HtmlApplication.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/html/HtmlController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/html/HtmlController.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/html/HtmlController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/html/HtmlController.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/idc/Application.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/Application.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/idc/Application.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/Application.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/idc/Book.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/Book.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/idc/Book.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/Book.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/idc/BookController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookController.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/idc/BookController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookController.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/idc/BookOperations.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookOperations.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/idc/BookOperations.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookOperations.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/idc/BookRepository.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookRepository.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/idc/BookRepository.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookRepository.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/model/Foo.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/model/Foo.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/model/Foo.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/model/Foo.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/persistence/DataSetupBean.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/persistence/DataSetupBean.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/persistence/DataSetupBean.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/persistence/DataSetupBean.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/persistence/FooRepository.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/persistence/FooRepository.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/persistence/FooRepository.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/persistence/FooRepository.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/web/FooController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/FooController.java similarity index 97% rename from spring-5-mvc/src/main/java/com/baeldung/web/FooController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/FooController.java index 137864cddd..8d8e03bbaf 100644 --- a/spring-5-mvc/src/main/java/com/baeldung/web/FooController.java +++ b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/FooController.java @@ -1,66 +1,66 @@ -package com.baeldung.web; - -import java.util.List; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.PageRequest; -import org.springframework.http.HttpStatus; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.server.ResponseStatusException; - -import com.baeldung.model.Foo; -import com.baeldung.persistence.FooRepository; - -@RestController -public class FooController { - - @Autowired - private FooRepository repo; - - // API - read - - @GetMapping("/foos/{id}") - @Validated - public Foo findById(@PathVariable @Min(0) final long id) { - return repo.findById(id).orElse(null); - } - - @GetMapping("/foos") - public List findAll() { - return repo.findAll(); - } - - @GetMapping( value="/foos", params = { "page", "size" }) - @Validated - public List findPaginated(@RequestParam("page") @Min(0) final int page, @Max(100) @RequestParam("size") final int size) { - return repo.findAll(PageRequest.of(page, size)).getContent(); - } - - // API - write - - @PutMapping("/foos/{id}") - @ResponseStatus(HttpStatus.OK) - public Foo update(@PathVariable("id") final String id, @RequestBody final Foo foo) { - return foo; - } - - @PostMapping("/foos") - @ResponseStatus(HttpStatus.CREATED) - public void create( @RequestBody final Foo foo) { - if (null == foo || null == foo.getName()) { - throw new ResponseStatusException(HttpStatus.BAD_REQUEST," 'name' is required"); - } - repo.save(foo); - } +package com.baeldung.web; + +import java.util.List; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.HttpStatus; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; + +import com.baeldung.model.Foo; +import com.baeldung.persistence.FooRepository; + +@RestController +public class FooController { + + @Autowired + private FooRepository repo; + + // API - read + + @GetMapping("/foos/{id}") + @Validated + public Foo findById(@PathVariable @Min(0) final long id) { + return repo.findById(id).orElse(null); + } + + @GetMapping("/foos") + public List findAll() { + return repo.findAll(); + } + + @GetMapping( value="/foos", params = { "page", "size" }) + @Validated + public List findPaginated(@RequestParam("page") @Min(0) final int page, @Max(100) @RequestParam("size") final int size) { + return repo.findAll(PageRequest.of(page, size)).getContent(); + } + + // API - write + + @PutMapping("/foos/{id}") + @ResponseStatus(HttpStatus.OK) + public Foo update(@PathVariable("id") final String id, @RequestBody final Foo foo) { + return foo; + } + + @PostMapping("/foos") + @ResponseStatus(HttpStatus.CREATED) + public void create( @RequestBody final Foo foo) { + if (null == foo || null == foo.getName()) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST," 'name' is required"); + } + repo.save(foo); + } } \ No newline at end of file diff --git a/spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/web/StreamingResponseBodyController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/StreamingResponseBodyController.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/web/StreamingResponseBodyController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/StreamingResponseBodyController.java diff --git a/spring-5-mvc/src/main/resources/application.properties b/spring-web-modules/spring-5-mvc/src/main/resources/application.properties similarity index 100% rename from spring-5-mvc/src/main/resources/application.properties rename to spring-web-modules/spring-5-mvc/src/main/resources/application.properties diff --git a/spring-5-mvc/src/main/resources/logback.xml b/spring-web-modules/spring-5-mvc/src/main/resources/logback.xml similarity index 100% rename from spring-5-mvc/src/main/resources/logback.xml rename to spring-web-modules/spring-5-mvc/src/main/resources/logback.xml diff --git a/spring-5-mvc/src/main/webapp/WEB-INF/jsp/index.jsp b/spring-web-modules/spring-5-mvc/src/main/webapp/WEB-INF/jsp/index.jsp similarity index 100% rename from spring-5-mvc/src/main/webapp/WEB-INF/jsp/index.jsp rename to spring-web-modules/spring-5-mvc/src/main/webapp/WEB-INF/jsp/index.jsp diff --git a/spring-5-mvc/src/main/webapp/WEB-INF/web.xml b/spring-web-modules/spring-5-mvc/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-5-mvc/src/main/webapp/WEB-INF/web.xml rename to spring-web-modules/spring-5-mvc/src/main/webapp/WEB-INF/web.xml diff --git a/spring-5-mvc/src/test/java/com/baeldung/LiveTest.java b/spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/LiveTest.java similarity index 100% rename from spring-5-mvc/src/test/java/com/baeldung/LiveTest.java rename to spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/LiveTest.java diff --git a/spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java b/spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java similarity index 100% rename from spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java rename to spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java diff --git a/spring-5-mvc/src/test/java/com/baeldung/html/HtmlControllerTest.java b/spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/html/HtmlControllerTest.java similarity index 100% rename from spring-5-mvc/src/test/java/com/baeldung/html/HtmlControllerTest.java rename to spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/html/HtmlControllerTest.java