From 0423536cf417fdbd1c380b5ae4b6fb685d6b1b4f Mon Sep 17 00:00:00 2001 From: kwoyke Date: Tue, 28 Jul 2020 06:01:54 +0200 Subject: [PATCH] JAVA-2113: Split or move spring-resttemplate module (#9753) * JAVA-2113: Move Proxies With RestTemplate to spring-resttemplate-2 * JAVA-2113: Move A Custom Media Type for a Spring REST API to spring-resttemplate-2 * JAVA-2113: Move RestTemplate Post Request with JSON to spring-resttemplate-2 * JAVA-2113: Move Download an Image or a File with Spring MVC to spring-boot-mvc-3 * JAVA-2113: Fix the test --- spring-boot-modules/spring-boot-mvc-3/README.md | 1 + spring-boot-modules/spring-boot-mvc-3/pom.xml | 9 +++++++++ .../baeldung/produceimage/ImageApplication.java | 0 .../controller/DataProducerController.java | 0 spring-resttemplate-2/README.md | 3 +++ .../RestTemplateConfigurationApplication.java | 13 +++++++++++++ .../resttemplate/web/controller/PersonAPI.java | 0 .../baeldung/resttemplate/web/dto/Person.java | 0 .../resttemplate/web/service/PersonService.java | 0 .../web/service/PersonServiceImpl.java | 0 .../baeldung/sampleapp/config/WebConfig.java | 17 +++++++++++++++++ .../mediatypes/CustomMediaTypeController.java | 0 .../sampleapp/web/dto/BaeldungItem.java | 0 .../sampleapp/web/dto/BaeldungItemV2.java | 0 .../postjson/PersonAPILiveTest.java | 0 .../proxy/RequestFactoryLiveTest.java | 0 .../proxy/RestTemplateCustomizerLiveTest.java | 0 ...ustomMediaTypeControllerIntegrationTest.java | 0 .../CustomMediaTypeControllerLiveTest.java | 0 .../web/controller/mediatypes/TestConfig.java | 0 spring-resttemplate/README.md | 5 ----- .../java/com/baeldung/SpringContextTest.java | 4 +--- 22 files changed, 44 insertions(+), 8 deletions(-) rename {spring-resttemplate => spring-boot-modules/spring-boot-mvc-3}/src/main/java/com/baeldung/produceimage/ImageApplication.java (100%) rename {spring-resttemplate => spring-boot-modules/spring-boot-mvc-3}/src/main/java/com/baeldung/produceimage/controller/DataProducerController.java (100%) create mode 100644 spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java rename {spring-resttemplate => spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/web/dto/Person.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/web/service/PersonService.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/web/service/PersonServiceImpl.java (100%) create mode 100644 spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/config/WebConfig.java rename {spring-resttemplate => spring-resttemplate-2}/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/test/java/com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/test/java/com/baeldung/resttemplate/proxy/RestTemplateCustomizerLiveTest.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerIntegrationTest.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerLiveTest.java (100%) rename {spring-resttemplate => spring-resttemplate-2}/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java (100%) diff --git a/spring-boot-modules/spring-boot-mvc-3/README.md b/spring-boot-modules/spring-boot-mvc-3/README.md index 58a3008966..0562224337 100644 --- a/spring-boot-modules/spring-boot-mvc-3/README.md +++ b/spring-boot-modules/spring-boot-mvc-3/README.md @@ -5,4 +5,5 @@ This module contains articles about Spring Web MVC in Spring Boot projects. ### Relevant Articles: - [Circular View Path Error](https://www.baeldung.com/spring-circular-view-path-error) +- [Download an Image or a File with Spring MVC](https://www.baeldung.com/spring-controller-return-image-file) - More articles: [[prev -->]](/spring-boot-modules/spring-boot-mvc-2) diff --git a/spring-boot-modules/spring-boot-mvc-3/pom.xml b/spring-boot-modules/spring-boot-mvc-3/pom.xml index 71b7383ef4..31c43461d2 100644 --- a/spring-boot-modules/spring-boot-mvc-3/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-3/pom.xml @@ -26,6 +26,15 @@ org.springframework.boot spring-boot-starter-thymeleaf + + commons-io + commons-io + ${commons-io.version} + + + 2.7 + + \ No newline at end of file diff --git a/spring-resttemplate/src/main/java/com/baeldung/produceimage/ImageApplication.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/produceimage/ImageApplication.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/produceimage/ImageApplication.java rename to spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/produceimage/ImageApplication.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/produceimage/controller/DataProducerController.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/produceimage/controller/DataProducerController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/produceimage/controller/DataProducerController.java rename to spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/produceimage/controller/DataProducerController.java diff --git a/spring-resttemplate-2/README.md b/spring-resttemplate-2/README.md index d7a8a8633a..e1e0ba40b0 100644 --- a/spring-resttemplate-2/README.md +++ b/spring-resttemplate-2/README.md @@ -5,3 +5,6 @@ This module contains articles about Spring RestTemplate ### Relevant Articles: - [Spring RestTemplate Request/Response Logging](https://www.baeldung.com/spring-resttemplate-logging) +- [Proxies With RestTemplate](https://www.baeldung.com/java-resttemplate-proxy) +- [A Custom Media Type for a Spring REST API](https://www.baeldung.com/spring-rest-custom-media-type) +- [RestTemplate Post Request with JSON](https://www.baeldung.com/spring-resttemplate-post-json) diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java new file mode 100644 index 0000000000..8df3c13d7b --- /dev/null +++ b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.resttemplate; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class RestTemplateConfigurationApplication { + + public static void main(String[] args) { + SpringApplication.run(RestTemplateConfigurationApplication.class, args); + } +} diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java rename to spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/dto/Person.java b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/dto/Person.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/dto/Person.java rename to spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/dto/Person.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/PersonService.java b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonService.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/PersonService.java rename to spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonService.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/PersonServiceImpl.java b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonServiceImpl.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/PersonServiceImpl.java rename to spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonServiceImpl.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/config/WebConfig.java b/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/config/WebConfig.java new file mode 100644 index 0000000000..cac12c6978 --- /dev/null +++ b/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/config/WebConfig.java @@ -0,0 +1,17 @@ +package com.baeldung.sampleapp.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@EnableWebMvc +@ComponentScan({ "com.baeldung.sampleapp.web" }) +public class WebConfig implements WebMvcConfigurer { + + public WebConfig() { + super(); + } + +} diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java b/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java rename to spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java b/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java rename to spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java b/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java rename to spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java b/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java rename to spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java b/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java rename to spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/resttemplate/proxy/RestTemplateCustomizerLiveTest.java b/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RestTemplateCustomizerLiveTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/resttemplate/proxy/RestTemplateCustomizerLiveTest.java rename to spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RestTemplateCustomizerLiveTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerIntegrationTest.java b/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerIntegrationTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerIntegrationTest.java rename to spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerIntegrationTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerLiveTest.java b/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerLiveTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerLiveTest.java rename to spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerLiveTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java b/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java rename to spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java diff --git a/spring-resttemplate/README.md b/spring-resttemplate/README.md index bbfda4f6b8..952f35e90b 100644 --- a/spring-resttemplate/README.md +++ b/spring-resttemplate/README.md @@ -11,16 +11,11 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Spring RestTemplate Error Handling](https://www.baeldung.com/spring-rest-template-error-handling) - [Configure a RestTemplate with RestTemplateBuilder](https://www.baeldung.com/spring-rest-template-builder) - [Mocking a RestTemplate in Spring](https://www.baeldung.com/spring-mock-rest-template) -- [RestTemplate Post Request with JSON](https://www.baeldung.com/spring-resttemplate-post-json) - [Download a Large File Through a Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-download-large-file) - [Using the Spring RestTemplate Interceptor](https://www.baeldung.com/spring-rest-template-interceptor) - [Uploading MultipartFile with Spring RestTemplate](https://www.baeldung.com/spring-rest-template-multipart-upload) - [Get and Post Lists of Objects with RestTemplate](https://www.baeldung.com/spring-rest-template-list) -- [Copy of RestTemplate Post Request with JSON](https://www.baeldung.com/spring-resttemplate-post-json-test) - [HTTP PUT vs HTTP PATCH in a REST API](https://www.baeldung.com/http-put-patch-difference-spring) -- [A Custom Media Type for a Spring REST API](https://www.baeldung.com/spring-rest-custom-media-type) -- [Download an Image or a File with Spring MVC](https://www.baeldung.com/spring-controller-return-image-file) -- [Proxies With RestTemplate](https://www.baeldung.com/java-resttemplate-proxy) ### NOTE: diff --git a/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java b/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java index 19d5eabd2b..43901cf37f 100644 --- a/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java +++ b/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java @@ -5,12 +5,10 @@ import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.produceimage.ImageApplication; import com.baeldung.responseheaders.ResponseHeadersApplication; @RunWith(SpringRunner.class) -@SpringBootTest(classes = { ImageApplication.class, - ResponseHeadersApplication.class, +@SpringBootTest(classes = { ResponseHeadersApplication.class, com.baeldung.web.upload.app.UploadApplication.class, }) public class SpringContextTest {