From 8bd7b324999b59716844656e63e01a16774cc28b Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Thu, 30 Jun 2022 15:11:18 +0530 Subject: [PATCH 01/35] Initial Changes for BAEL-5297 --- .../exception/NotFoundException.java | 4 ++- .../fileupload/controller/FileController.java | 5 ++-- .../fileupload/service/FileUploadClient.java | 15 ++++++++++ .../FileUploadClientFallbackFactory.java | 30 +++++++++++++++++++ .../fileupload/service/UploadService.java | 7 +++++ 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java index 28d0e95e9a..1aba89e330 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java @@ -2,7 +2,9 @@ package com.baeldung.cloud.openfeign.exception; public class NotFoundException extends Exception { - public NotFoundException() { + private static final long serialVersionUID = 1L; + + public NotFoundException() { } public NotFoundException(String message) { diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java index 1ddbfcea81..102f9825e0 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java @@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import com.baeldung.cloud.openfeign.exception.NotFoundException; import com.baeldung.cloud.openfeign.fileupload.service.UploadService; @RestController @@ -26,8 +27,8 @@ public class FileController { } @PostMapping(value = "/upload-error") - public String handleFileUploadError(@RequestPart(value = "file") MultipartFile file) { - return service.uploadFile(file); + public String handleFileUploadError(@RequestPart(value = "file") MultipartFile file) throws NotFoundException { + return service.uploadFileWithCause(file); } } \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java new file mode 100644 index 0000000000..f7f54138de --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java @@ -0,0 +1,15 @@ +package com.baeldung.cloud.openfeign.fileupload.service; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig; + +@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class, fallbackFactory = FileUploadClientFallbackFactory.class) +public interface FileUploadClient { + @PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + String fileUpload(@RequestPart(value = "file") MultipartFile file); +} diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java new file mode 100644 index 0000000000..74e1e703a9 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java @@ -0,0 +1,30 @@ +package com.baeldung.cloud.openfeign.fileupload.service; + +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import com.baeldung.cloud.openfeign.exception.BadRequestException; +import com.baeldung.cloud.openfeign.exception.NotFoundException; + +@Component +public class FileUploadClientFallbackFactory implements FallbackFactory { + @Override + public FileUploadClient create(Throwable cause) { + return new FileUploadClient() { + @Override + public String fileUpload(MultipartFile file) { + if (cause instanceof BadRequestException) { + return "Bad Request!!!"; + } + if (cause instanceof NotFoundException) { + return "Not Found!!!"; + } + if (cause instanceof Exception) { + return "Exception!!!"; + } + return "Successfully Uploaded file!!!"; + } + }; + } +} \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java index 742a37668b..e9db87b532 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java @@ -4,6 +4,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import com.baeldung.cloud.openfeign.exception.NotFoundException; + import feign.Feign; import feign.Response; import feign.form.spring.SpringFormEncoder; @@ -14,6 +16,8 @@ public class UploadService { @Autowired private UploadClient client; + @Autowired + private FileUploadClient fileUploadClient; public boolean uploadFileWithManualClient(MultipartFile file) { UploadResource fileUploadResource = Feign.builder().encoder(new SpringFormEncoder()) @@ -30,4 +34,7 @@ public class UploadService { return client.fileUpload(file); } + public String uploadFileWithCause(MultipartFile file) throws NotFoundException { + return fileUploadClient.fileUpload(file); + } } \ No newline at end of file From 9b7f11418ee10e43c21b94efda99eccc246d0d53 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Sun, 10 Jul 2022 05:09:50 +0530 Subject: [PATCH 02/35] Update FileUploadClientFallbackFactory.java Changes for creating FallbackFactory --- .../FileUploadClientFallbackFactory.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java index 74e1e703a9..2ccb2709a0 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java @@ -9,22 +9,22 @@ import com.baeldung.cloud.openfeign.exception.NotFoundException; @Component public class FileUploadClientFallbackFactory implements FallbackFactory { - @Override - public FileUploadClient create(Throwable cause) { - return new FileUploadClient() { - @Override - public String fileUpload(MultipartFile file) { - if (cause instanceof BadRequestException) { - return "Bad Request!!!"; - } - if (cause instanceof NotFoundException) { - return "Not Found!!!"; - } - if (cause instanceof Exception) { - return "Exception!!!"; - } - return "Successfully Uploaded file!!!"; - } - }; - } + @Override + public FileUploadClient create(Throwable cause) { + return new FileUploadClient() { + @Override + public String fileUpload(MultipartFile file) { + if (cause instanceof BadRequestException) { + return "Bad Request!!!"; + } + if (cause instanceof NotFoundException) { + return "Not Found!!!"; + } + if (cause instanceof Exception) { + return "Exception!!!"; + } + return "Successfully Uploaded file!!!"; + } + }; + } } \ No newline at end of file From 7f4cae20b030549da435a52d0f65b581c40a2200 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 18 Jul 2022 07:25:37 +0530 Subject: [PATCH 03/35] Update NotFoundException.java --- .../cloud/openfeign/exception/NotFoundException.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java index 1aba89e330..19f6204b86 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java @@ -2,11 +2,6 @@ package com.baeldung.cloud.openfeign.exception; public class NotFoundException extends Exception { - private static final long serialVersionUID = 1L; - - public NotFoundException() { - } - public NotFoundException(String message) { super(message); } @@ -17,7 +12,7 @@ public class NotFoundException extends Exception { @Override public String toString() { - return "NotFoundException: "+getMessage(); + return "NotFoundException: " + getMessage(); } } From 3574fa6fa247c6b3c9c3fd604edb3455633b5d41 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 18 Jul 2022 07:26:21 +0530 Subject: [PATCH 04/35] Update CustomErrorDecoder.java --- .../com/baeldung/cloud/openfeign/config/CustomErrorDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/config/CustomErrorDecoder.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/config/CustomErrorDecoder.java index 4d32cf083f..303a5db526 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/config/CustomErrorDecoder.java +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/config/CustomErrorDecoder.java @@ -13,7 +13,7 @@ public class CustomErrorDecoder implements ErrorDecoder { case 400: return new BadRequestException(); case 404: - return new NotFoundException(); + return new NotFoundException("Not found !!!"); default: return new Exception("Generic error"); } From 911620c67666678ddd1d892d288e708bd3a3fb3a Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 22 Jul 2022 16:38:10 +0530 Subject: [PATCH 05/35] Initial Changes for Creating new Module-2 --- .../spring-cloud-openfeign-2/README.md | 9 +++ .../spring-cloud-openfeign-2/pom.xml | 71 +++++++++++++++++++ .../cloud/openfeign/ExampleApplication.java | 16 +++++ .../openfeign/config/ClientConfiguration.java | 21 ++++++ .../exception/BadRequestException.java | 21 ++++++ .../exception/NotFoundException.java | 18 +++++ .../fileupload/config/ExceptionMessage.java | 55 ++++++++++++++ .../fileupload/config/FeignSupportConfig.java | 28 ++++++++ .../config/RetreiveMessageErrorDecoder.java | 35 +++++++++ .../fileupload/controller/FileController.java | 34 +++++++++ .../fileupload/service/FileUploadClient.java | 15 ++++ .../FileUploadClientFallbackFactory.java | 30 ++++++++ .../fileupload/service/UploadClient.java | 18 +++++ .../fileupload/service/UploadResource.java | 16 +++++ .../fileupload/service/UploadService.java | 36 ++++++++++ .../src/main/resources/application.properties | 10 +++ .../src/main/resources/fileupload.txt | 0 .../OpenFeignFileUploadLiveTest.java | 50 +++++++++++++ .../cloud/openfeign/SpringContextTest.java | 16 +++++ 19 files changed, 499 insertions(+) create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/README.md create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/pom.xml create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/ExampleApplication.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/config/ClientConfiguration.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/exception/BadRequestException.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/ExceptionMessage.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/FeignSupportConfig.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/RetreiveMessageErrorDecoder.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadClient.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadResource.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/resources/application.properties create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/resources/fileupload.txt create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/README.md b/spring-cloud-modules/spring-cloud-openfeign-2/README.md new file mode 100644 index 0000000000..a369da96da --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/README.md @@ -0,0 +1,9 @@ +### Relevant Articles: + +- [Introduction to Spring Cloud OpenFeign](https://www.baeldung.com/spring-cloud-openfeign) +- [Differences Between Netflix Feign and OpenFeign](https://www.baeldung.com/netflix-feign-vs-openfeign) +- [File Upload With Open Feign](https://www.baeldung.com/java-feign-file-upload) +- [Feign Logging Configuration](https://www.baeldung.com/java-feign-logging) +- [Provide an OAuth2 Token to a Feign Client](https://www.baeldung.com/spring-cloud-feign-oauth-token) +- [Retrieve Original Message From Feign ErrorDecoder](https://www.baeldung.com/feign-retrieve-original-message) +- [RequestLine with Feign Client](https://www.baeldung.com/feign-requestline) diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml b/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml new file mode 100644 index 0000000000..1e968e5d00 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + com.baeldung.cloud + spring-cloud-openfeign-2 + spring-cloud-openfeign-2 + OpenFeign project for Spring Boot + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + io.github.openfeign + feign-okhttp + + + org.springframework.boot + spring-boot-starter-web + + + io.github.openfeign.form + feign-form + 3.8.0 + + + io.github.openfeign.form + feign-form-spring + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.security + spring-security-oauth2-client + + + org.springframework.boot + spring-boot-starter-test + test + + + + + 2021.0.0 + + + \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/ExampleApplication.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/ExampleApplication.java new file mode 100644 index 0000000000..c7f07f6667 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/ExampleApplication.java @@ -0,0 +1,16 @@ +package com.baeldung.cloud.openfeign; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@SpringBootApplication +@EnableFeignClients +public class ExampleApplication { + + public static void main(String[] args) { + SpringApplication.run(ExampleApplication.class, args); + } + +} + diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/config/ClientConfiguration.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/config/ClientConfiguration.java new file mode 100644 index 0000000000..801bd6c729 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/config/ClientConfiguration.java @@ -0,0 +1,21 @@ +package com.baeldung.cloud.openfeign.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import feign.Logger; +import feign.codec.ErrorDecoder; + +@Configuration +public class ClientConfiguration { + + @Bean + public Logger.Level feignLoggerLevel() { + return Logger.Level.FULL; + } + + @Bean + public ErrorDecoder errorDecoder() { + return new ErrorDecoder.Default(); + } +} diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/exception/BadRequestException.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/exception/BadRequestException.java new file mode 100644 index 0000000000..7c2daf43fe --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/exception/BadRequestException.java @@ -0,0 +1,21 @@ +package com.baeldung.cloud.openfeign.exception; + +public class BadRequestException extends Exception { + + public BadRequestException() { + } + + public BadRequestException(String message) { + super(message); + } + + public BadRequestException(Throwable cause) { + super(cause); + } + + @Override + public String toString() { + return "BadRequestException: " + getMessage(); + } + +} diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java new file mode 100644 index 0000000000..19f6204b86 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/exception/NotFoundException.java @@ -0,0 +1,18 @@ +package com.baeldung.cloud.openfeign.exception; + +public class NotFoundException extends Exception { + + public NotFoundException(String message) { + super(message); + } + + public NotFoundException(Throwable cause) { + super(cause); + } + + @Override + public String toString() { + return "NotFoundException: " + getMessage(); + } + +} diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/ExceptionMessage.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/ExceptionMessage.java new file mode 100644 index 0000000000..45a555b2ea --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/ExceptionMessage.java @@ -0,0 +1,55 @@ +package com.baeldung.cloud.openfeign.fileupload.config; + +public class ExceptionMessage { + private String timestamp; + private int status; + private String error; + private String message; + private String path; + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Override + public String toString() { + return "ExceptionMessage [timestamp=" + timestamp + ", status=" + status + ", error=" + error + ", message=" + message + ", path=" + path + "]"; + } + +} diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/FeignSupportConfig.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/FeignSupportConfig.java new file mode 100644 index 0000000000..802077a3d7 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/FeignSupportConfig.java @@ -0,0 +1,28 @@ +package com.baeldung.cloud.openfeign.fileupload.config; + +import org.springframework.beans.factory.ObjectFactory; +import org.springframework.boot.autoconfigure.http.HttpMessageConverters; +import org.springframework.cloud.openfeign.support.SpringEncoder; +import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; + +import feign.codec.Encoder; +import feign.codec.ErrorDecoder; +import feign.form.spring.SpringFormEncoder; + +public class FeignSupportConfig { + @Bean + public Encoder multipartFormEncoder() { + return new SpringFormEncoder(new SpringEncoder(new ObjectFactory() { + @Override + public HttpMessageConverters getObject() { + return new HttpMessageConverters(new RestTemplate().getMessageConverters()); + } + })); + } + + @Bean + public ErrorDecoder errorDecoder() { + return new RetreiveMessageErrorDecoder(); + } +} diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/RetreiveMessageErrorDecoder.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/RetreiveMessageErrorDecoder.java new file mode 100644 index 0000000000..09bf8bf54b --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/RetreiveMessageErrorDecoder.java @@ -0,0 +1,35 @@ +package com.baeldung.cloud.openfeign.fileupload.config; + +import java.io.IOException; +import java.io.InputStream; + +import com.baeldung.cloud.openfeign.exception.BadRequestException; +import com.baeldung.cloud.openfeign.exception.NotFoundException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import feign.Response; +import feign.codec.ErrorDecoder; + +public class RetreiveMessageErrorDecoder implements ErrorDecoder { + private final ErrorDecoder errorDecoder = new Default(); + + @Override + public Exception decode(String methodKey, Response response) { + ExceptionMessage message = null; + try (InputStream bodyIs = response.body() + .asInputStream()) { + ObjectMapper mapper = new ObjectMapper(); + message = mapper.readValue(bodyIs, ExceptionMessage.class); + } catch (IOException e) { + return new Exception(e.getMessage()); + } + switch (response.status()) { + case 400: + return new BadRequestException(message.getMessage() != null ? message.getMessage() : "Bad Request"); + case 404: + return new NotFoundException(message.getMessage() != null ? message.getMessage() : "Not found"); + default: + return errorDecoder.decode(methodKey, response); + } + } +} diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java new file mode 100644 index 0000000000..102f9825e0 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java @@ -0,0 +1,34 @@ +package com.baeldung.cloud.openfeign.fileupload.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import com.baeldung.cloud.openfeign.exception.NotFoundException; +import com.baeldung.cloud.openfeign.fileupload.service.UploadService; + +@RestController +public class FileController { + + @Autowired + private UploadService service; + + @PostMapping(value = "/upload") + public String handleFileUpload(@RequestPart(value = "file") MultipartFile file) { + return service.uploadFile(file); + } + + @PostMapping(value = "/upload-mannual-client") + public boolean handleFileUploadWithManualClient( + @RequestPart(value = "file") MultipartFile file) { + return service.uploadFileWithManualClient(file); + } + + @PostMapping(value = "/upload-error") + public String handleFileUploadError(@RequestPart(value = "file") MultipartFile file) throws NotFoundException { + return service.uploadFileWithCause(file); + } + +} \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java new file mode 100644 index 0000000000..f7f54138de --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java @@ -0,0 +1,15 @@ +package com.baeldung.cloud.openfeign.fileupload.service; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig; + +@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class, fallbackFactory = FileUploadClientFallbackFactory.class) +public interface FileUploadClient { + @PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + String fileUpload(@RequestPart(value = "file") MultipartFile file); +} diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java new file mode 100644 index 0000000000..2ccb2709a0 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java @@ -0,0 +1,30 @@ +package com.baeldung.cloud.openfeign.fileupload.service; + +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import com.baeldung.cloud.openfeign.exception.BadRequestException; +import com.baeldung.cloud.openfeign.exception.NotFoundException; + +@Component +public class FileUploadClientFallbackFactory implements FallbackFactory { + @Override + public FileUploadClient create(Throwable cause) { + return new FileUploadClient() { + @Override + public String fileUpload(MultipartFile file) { + if (cause instanceof BadRequestException) { + return "Bad Request!!!"; + } + if (cause instanceof NotFoundException) { + return "Not Found!!!"; + } + if (cause instanceof Exception) { + return "Exception!!!"; + } + return "Successfully Uploaded file!!!"; + } + }; + } +} \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadClient.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadClient.java new file mode 100644 index 0000000000..8f3ef7e421 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadClient.java @@ -0,0 +1,18 @@ +package com.baeldung.cloud.openfeign.fileupload.service; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig; + +@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class) +public interface UploadClient { + @PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + String fileUpload(@RequestPart(value = "file") MultipartFile file); + + @PostMapping(value = "/upload-file-error", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + String fileUploadError(@RequestPart(value = "file") MultipartFile file); +} diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadResource.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadResource.java new file mode 100644 index 0000000000..26e658a7f0 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadResource.java @@ -0,0 +1,16 @@ +package com.baeldung.cloud.openfeign.fileupload.service; + +import org.springframework.web.multipart.MultipartFile; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import feign.Response; + +public interface UploadResource { + + @RequestLine("POST /upload-file") + @Headers("Content-Type: multipart/form-data") + Response uploadFile(@Param("file") MultipartFile file); + +} \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java new file mode 100644 index 0000000000..8a91607562 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java @@ -0,0 +1,36 @@ +package com.baeldung.cloud.openfeign.fileupload.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import com.baeldung.cloud.openfeign.exception.NotFoundException; + +import feign.Feign; +import feign.Response; +import feign.form.spring.SpringFormEncoder; + +@Service +public class UploadService { + private static final String HTTP_FILE_UPLOAD_URL = "http://localhost:8081"; + + @Autowired + private UploadClient client; + @Autowired + private FileUploadClient fileUploadClient; + + public boolean uploadFileWithManualClient(MultipartFile file) { + UploadResource fileUploadResource = Feign.builder().encoder(new SpringFormEncoder()) + .target(UploadResource.class, HTTP_FILE_UPLOAD_URL); + Response response = fileUploadResource.uploadFile(file); + return response.status() == 200; + } + + public String uploadFile(MultipartFile file) { + return client.fileUpload(file); + } + + public String uploadFileWithCause(MultipartFile file) throws NotFoundException { + return fileUploadClient.fileUpload(file); + } +} \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/resources/application.properties b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/resources/application.properties new file mode 100644 index 0000000000..7188b74c9b --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/resources/application.properties @@ -0,0 +1,10 @@ +server.port=8085 +spring.main.allow-bean-definition-overriding=true +spring.application.name= openfeign +logging.level.com.baeldung.cloud.openfeign.client: DEBUG +feign.hystrix.enabled=true + +spring.security.oauth2.client.registration.keycloak.authorization-grant-type=client_credentials +spring.security.oauth2.client.registration.keycloak.client-id=payment-app +spring.security.oauth2.client.registration.keycloak.client-secret=863e9de4-33d4-4471-b35e-f8d2434385bb +spring.security.oauth2.client.provider.keycloak.token-uri=http://localhost:8083/auth/realms/master/protocol/openid-connect/token diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/resources/fileupload.txt b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/resources/fileupload.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java new file mode 100644 index 0000000000..f558e07491 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java @@ -0,0 +1,50 @@ +package com.baeldung.cloud.openfeign; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +import org.apache.commons.io.IOUtils; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.multipart.MultipartFile; + +import com.baeldung.cloud.openfeign.fileupload.service.UploadService; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class OpenFeignFileUploadLiveTest { + + @Autowired + private UploadService uploadService; + + private static String FILE_NAME = "fileupload.txt"; + + @Test + public void whenFeignBuilder_thenFileUploadSuccess() throws IOException { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + File file = new File(classloader.getResource(FILE_NAME).getFile()); + Assert.assertTrue(file.exists()); + FileInputStream input = new FileInputStream(file); + MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", + IOUtils.toByteArray(input)); + Assert.assertTrue(uploadService.uploadFileWithManualClient(multipartFile)); + } + + @Test + public void whenAnnotatedFeignClient_thenFileUploadSuccess() throws IOException { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + File file = new File(classloader.getResource(FILE_NAME).getFile()); + Assert.assertTrue(file.exists()); + FileInputStream input = new FileInputStream(file); + MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", + IOUtils.toByteArray(input)); + String uploadFile = uploadService.uploadFile(multipartFile); + Assert.assertNotNull(uploadFile); + } +} diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/SpringContextTest.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/SpringContextTest.java new file mode 100644 index 0000000000..4bf35f74f4 --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/SpringContextTest.java @@ -0,0 +1,16 @@ +package com.baeldung.cloud.openfeign; + + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ExampleApplication.class) +public class SpringContextTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} From f9b412ebb1f6cca7d30162bfe1a3dd4091fa224b Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 22 Jul 2022 16:43:08 +0530 Subject: [PATCH 06/35] Removed changes for FallbackFactory --- .../fileupload/service/FileUploadClient.java | 2 +- .../FileUploadClientFallbackFactory.java | 30 ------------------- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java index f7f54138de..bb5524c30e 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java @@ -8,7 +8,7 @@ import org.springframework.web.multipart.MultipartFile; import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig; -@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class, fallbackFactory = FileUploadClientFallbackFactory.class) +@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class) public interface FileUploadClient { @PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) String fileUpload(@RequestPart(value = "file") MultipartFile file); diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java deleted file mode 100644 index 2ccb2709a0..0000000000 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.cloud.openfeign.fileupload.service; - -import org.springframework.cloud.openfeign.FallbackFactory; -import org.springframework.stereotype.Component; -import org.springframework.web.multipart.MultipartFile; - -import com.baeldung.cloud.openfeign.exception.BadRequestException; -import com.baeldung.cloud.openfeign.exception.NotFoundException; - -@Component -public class FileUploadClientFallbackFactory implements FallbackFactory { - @Override - public FileUploadClient create(Throwable cause) { - return new FileUploadClient() { - @Override - public String fileUpload(MultipartFile file) { - if (cause instanceof BadRequestException) { - return "Bad Request!!!"; - } - if (cause instanceof NotFoundException) { - return "Not Found!!!"; - } - if (cause instanceof Exception) { - return "Exception!!!"; - } - return "Successfully Uploaded file!!!"; - } - }; - } -} \ No newline at end of file From 3999f0f9a44dcd7ced94e7617942afd521a13941 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 22 Jul 2022 16:47:09 +0530 Subject: [PATCH 07/35] Update README.md --- spring-cloud-modules/spring-cloud-openfeign/README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign/README.md b/spring-cloud-modules/spring-cloud-openfeign/README.md index a369da96da..d26165dfdd 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/README.md +++ b/spring-cloud-modules/spring-cloud-openfeign/README.md @@ -1,9 +1,4 @@ ### Relevant Articles: -- [Introduction to Spring Cloud OpenFeign](https://www.baeldung.com/spring-cloud-openfeign) -- [Differences Between Netflix Feign and OpenFeign](https://www.baeldung.com/netflix-feign-vs-openfeign) - [File Upload With Open Feign](https://www.baeldung.com/java-feign-file-upload) -- [Feign Logging Configuration](https://www.baeldung.com/java-feign-logging) -- [Provide an OAuth2 Token to a Feign Client](https://www.baeldung.com/spring-cloud-feign-oauth-token) -- [Retrieve Original Message From Feign ErrorDecoder](https://www.baeldung.com/feign-retrieve-original-message) -- [RequestLine with Feign Client](https://www.baeldung.com/feign-requestline) + From df300eb6b3e13e3e2931701d4fbeeb7709190d99 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 22 Jul 2022 16:47:48 +0530 Subject: [PATCH 08/35] Update README.md --- spring-cloud-modules/spring-cloud-openfeign/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign/README.md b/spring-cloud-modules/spring-cloud-openfeign/README.md index d26165dfdd..a369da96da 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/README.md +++ b/spring-cloud-modules/spring-cloud-openfeign/README.md @@ -1,4 +1,9 @@ ### Relevant Articles: +- [Introduction to Spring Cloud OpenFeign](https://www.baeldung.com/spring-cloud-openfeign) +- [Differences Between Netflix Feign and OpenFeign](https://www.baeldung.com/netflix-feign-vs-openfeign) - [File Upload With Open Feign](https://www.baeldung.com/java-feign-file-upload) - +- [Feign Logging Configuration](https://www.baeldung.com/java-feign-logging) +- [Provide an OAuth2 Token to a Feign Client](https://www.baeldung.com/spring-cloud-feign-oauth-token) +- [Retrieve Original Message From Feign ErrorDecoder](https://www.baeldung.com/feign-retrieve-original-message) +- [RequestLine with Feign Client](https://www.baeldung.com/feign-requestline) From 717afd3f5efe3806aae9689a7abf759649044f0f Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 22 Jul 2022 16:48:26 +0530 Subject: [PATCH 09/35] Update README.md --- spring-cloud-modules/spring-cloud-openfeign-2/README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/README.md b/spring-cloud-modules/spring-cloud-openfeign-2/README.md index a369da96da..a4cd84bb2b 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/README.md +++ b/spring-cloud-modules/spring-cloud-openfeign-2/README.md @@ -1,9 +1,3 @@ ### Relevant Articles: - [Introduction to Spring Cloud OpenFeign](https://www.baeldung.com/spring-cloud-openfeign) -- [Differences Between Netflix Feign and OpenFeign](https://www.baeldung.com/netflix-feign-vs-openfeign) -- [File Upload With Open Feign](https://www.baeldung.com/java-feign-file-upload) -- [Feign Logging Configuration](https://www.baeldung.com/java-feign-logging) -- [Provide an OAuth2 Token to a Feign Client](https://www.baeldung.com/spring-cloud-feign-oauth-token) -- [Retrieve Original Message From Feign ErrorDecoder](https://www.baeldung.com/feign-retrieve-original-message) -- [RequestLine with Feign Client](https://www.baeldung.com/feign-requestline) From 24a8399b6bede9eac46d2ce389b5df7da8b5f065 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 22 Jul 2022 16:52:08 +0530 Subject: [PATCH 10/35] Remove unwanted changes from Old Module --- .../fileupload/controller/FileController.java | 5 ++--- .../fileupload/service/FileUploadClient.java | 15 --------------- .../fileupload/service/UploadService.java | 10 +--------- 3 files changed, 3 insertions(+), 27 deletions(-) delete mode 100644 spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java index 102f9825e0..1ddbfcea81 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java @@ -6,7 +6,6 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import com.baeldung.cloud.openfeign.exception.NotFoundException; import com.baeldung.cloud.openfeign.fileupload.service.UploadService; @RestController @@ -27,8 +26,8 @@ public class FileController { } @PostMapping(value = "/upload-error") - public String handleFileUploadError(@RequestPart(value = "file") MultipartFile file) throws NotFoundException { - return service.uploadFileWithCause(file); + public String handleFileUploadError(@RequestPart(value = "file") MultipartFile file) { + return service.uploadFile(file); } } \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java deleted file mode 100644 index bb5524c30e..0000000000 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.cloud.openfeign.fileupload.service; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig; - -@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class) -public interface FileUploadClient { - @PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - String fileUpload(@RequestPart(value = "file") MultipartFile file); -} diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java index e9db87b532..c0d1962a71 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java @@ -4,8 +4,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; -import com.baeldung.cloud.openfeign.exception.NotFoundException; - import feign.Feign; import feign.Response; import feign.form.spring.SpringFormEncoder; @@ -16,9 +14,7 @@ public class UploadService { @Autowired private UploadClient client; - @Autowired - private FileUploadClient fileUploadClient; - + public boolean uploadFileWithManualClient(MultipartFile file) { UploadResource fileUploadResource = Feign.builder().encoder(new SpringFormEncoder()) .target(UploadResource.class, HTTP_FILE_UPLOAD_URL); @@ -33,8 +29,4 @@ public class UploadService { public String uploadFileError(MultipartFile file) { return client.fileUpload(file); } - - public String uploadFileWithCause(MultipartFile file) throws NotFoundException { - return fileUploadClient.fileUpload(file); - } } \ No newline at end of file From 896ab2d7da40090ea948168ca3213c4096e2cf56 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Sat, 23 Jul 2022 07:25:28 +0530 Subject: [PATCH 11/35] Update RetreiveMessageErrorDecoder.java --- .../openfeign/fileupload/config/RetreiveMessageErrorDecoder.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/RetreiveMessageErrorDecoder.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/RetreiveMessageErrorDecoder.java index 09bf8bf54b..5ebd7b6887 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/RetreiveMessageErrorDecoder.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/config/RetreiveMessageErrorDecoder.java @@ -12,7 +12,6 @@ import feign.codec.ErrorDecoder; public class RetreiveMessageErrorDecoder implements ErrorDecoder { private final ErrorDecoder errorDecoder = new Default(); - @Override public Exception decode(String methodKey, Response response) { ExceptionMessage message = null; From 200f80227783f8cd01e8bac8bc14c735db7964c1 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 25 Jul 2022 07:12:06 +0530 Subject: [PATCH 12/35] Changes to add fallback option. --- .../fileupload/controller/FileController.java | 24 ++++++++------ .../FileUploadClientFallbackFactory.java | 6 ++-- ...java => FileUploadClientWithFallBack.java} | 4 +-- ... FileUploadClientWithFallbackFactory.java} | 7 ++--- .../FileUploadClientWithFallbackImpl.java | 31 +++++++++++++++++++ .../fileupload/service/UploadService.java | 16 +++++----- 6 files changed, 61 insertions(+), 27 deletions(-) rename spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/{FileUploadClient.java => FileUploadClientWithFallBack.java} (73%) rename spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/{UploadClient.java => FileUploadClientWithFallbackFactory.java} (64%) create mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackImpl.java diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java index 102f9825e0..ed726cdb6c 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java @@ -15,20 +15,26 @@ public class FileController { @Autowired private UploadService service; - @PostMapping(value = "/upload") - public String handleFileUpload(@RequestPart(value = "file") MultipartFile file) { - return service.uploadFile(file); - } - @PostMapping(value = "/upload-mannual-client") public boolean handleFileUploadWithManualClient( @RequestPart(value = "file") MultipartFile file) { return service.uploadFileWithManualClient(file); } - @PostMapping(value = "/upload-error") - public String handleFileUploadError(@RequestPart(value = "file") MultipartFile file) throws NotFoundException { - return service.uploadFileWithCause(file); + @PostMapping(value = "/upload-file") + public boolean handleFileUpload(@RequestPart(value = "file") MultipartFile file) { + return service.uploadFileWithManualClient(file); } - + + @PostMapping(value = "/upload-with-fallbackfactory") + public String uploadFileWithFallbackFactory(@RequestPart(value = "file") MultipartFile file) + throws NotFoundException { + return service.uploadFileWithFallbackFactory(file); + } + + @PostMapping(value = "/upload-with-fallback") + public String uploadFileWithFallback(@RequestPart(value = "file") MultipartFile file) throws NotFoundException { + return service.uploadFileWithFallback(file); + } + } \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java index 2ccb2709a0..105be15192 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java @@ -8,10 +8,10 @@ import com.baeldung.cloud.openfeign.exception.BadRequestException; import com.baeldung.cloud.openfeign.exception.NotFoundException; @Component -public class FileUploadClientFallbackFactory implements FallbackFactory { +public class FileUploadClientFallbackFactory implements FallbackFactory { @Override - public FileUploadClient create(Throwable cause) { - return new FileUploadClient() { + public FileUploadClientWithFallbackFactory create(Throwable cause) { + return new FileUploadClientWithFallbackFactory() { @Override public String fileUpload(MultipartFile file) { if (cause instanceof BadRequestException) { diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallBack.java similarity index 73% rename from spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java rename to spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallBack.java index f7f54138de..a7ca3d6147 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallBack.java @@ -8,8 +8,8 @@ import org.springframework.web.multipart.MultipartFile; import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig; -@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class, fallbackFactory = FileUploadClientFallbackFactory.class) -public interface FileUploadClient { +@FeignClient(name = "file", url = "http://localhost:8080", configuration = FeignSupportConfig.class, fallback = FileUploadClientWithFallbackImpl.class) +public interface FileUploadClientWithFallBack { @PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) String fileUpload(@RequestPart(value = "file") MultipartFile file); } diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadClient.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackFactory.java similarity index 64% rename from spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadClient.java rename to spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackFactory.java index 8f3ef7e421..abf9892c19 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadClient.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackFactory.java @@ -8,11 +8,8 @@ import org.springframework.web.multipart.MultipartFile; import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig; -@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class) -public interface UploadClient { +@FeignClient(name = "file", url = "http://localhost:8080", configuration = FeignSupportConfig.class, fallbackFactory = FileUploadClientFallbackFactory.class) +public interface FileUploadClientWithFallbackFactory { @PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) String fileUpload(@RequestPart(value = "file") MultipartFile file); - - @PostMapping(value = "/upload-file-error", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - String fileUploadError(@RequestPart(value = "file") MultipartFile file); } diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackImpl.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackImpl.java new file mode 100644 index 0000000000..b41a7f3c5d --- /dev/null +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackImpl.java @@ -0,0 +1,31 @@ +package com.baeldung.cloud.openfeign.fileupload.service; + +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import com.baeldung.cloud.openfeign.exception.BadRequestException; +import com.baeldung.cloud.openfeign.exception.NotFoundException; + +@Component +public class FileUploadClientWithFallbackImpl implements FileUploadClientWithFallBack { + + @Override + public String fileUpload(MultipartFile file) { + try { + throw new NotFoundException("hi, something wrong"); + } catch (Exception ex) { + + if (ex instanceof BadRequestException) { + return "Bad Request!!!"; + } + if (ex instanceof NotFoundException) { + return "Not Found!!!"; + } + if (ex instanceof Exception) { + return "Exception!!!"; + } + return "Successfully Uploaded file!!!"; + } + } + +} diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java index 8a91607562..31b4e385ed 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java @@ -12,12 +12,12 @@ import feign.form.spring.SpringFormEncoder; @Service public class UploadService { - private static final String HTTP_FILE_UPLOAD_URL = "http://localhost:8081"; + private static final String HTTP_FILE_UPLOAD_URL = "http://localhost:8080"; @Autowired - private UploadClient client; + private FileUploadClientWithFallbackFactory fileUploadClient; @Autowired - private FileUploadClient fileUploadClient; + private FileUploadClientWithFallBack fileUploadClientWithFallback; public boolean uploadFileWithManualClient(MultipartFile file) { UploadResource fileUploadResource = Feign.builder().encoder(new SpringFormEncoder()) @@ -25,12 +25,12 @@ public class UploadService { Response response = fileUploadResource.uploadFile(file); return response.status() == 200; } - - public String uploadFile(MultipartFile file) { - return client.fileUpload(file); - } - public String uploadFileWithCause(MultipartFile file) throws NotFoundException { + public String uploadFileWithFallbackFactory(MultipartFile file) throws NotFoundException { return fileUploadClient.fileUpload(file); } + + public String uploadFileWithFallback(MultipartFile file) throws NotFoundException { + return fileUploadClientWithFallback.fileUpload(file); + } } \ No newline at end of file From 07b65a6d33e2d4331baaa8ee607c948d335d46a6 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 25 Jul 2022 07:15:20 +0530 Subject: [PATCH 13/35] Changes for fallback option --- .../fileupload/controller/FileController.java | 15 ++++++--------- .../fileupload/service/UploadService.java | 6 ++---- .../openfeign/OpenFeignFileUploadLiveTest.java | 5 ++--- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java index ed726cdb6c..147c3f5498 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java @@ -6,34 +6,31 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import com.baeldung.cloud.openfeign.exception.NotFoundException; import com.baeldung.cloud.openfeign.fileupload.service.UploadService; @RestController public class FileController { - + @Autowired private UploadService service; - + @PostMapping(value = "/upload-mannual-client") - public boolean handleFileUploadWithManualClient( - @RequestPart(value = "file") MultipartFile file) { + public boolean handleFileUploadWithManualClient(@RequestPart(value = "file") MultipartFile file) { return service.uploadFileWithManualClient(file); } - + @PostMapping(value = "/upload-file") public boolean handleFileUpload(@RequestPart(value = "file") MultipartFile file) { return service.uploadFileWithManualClient(file); } @PostMapping(value = "/upload-with-fallbackfactory") - public String uploadFileWithFallbackFactory(@RequestPart(value = "file") MultipartFile file) - throws NotFoundException { + public String uploadFileWithFallbackFactory(@RequestPart(value = "file") MultipartFile file) { return service.uploadFileWithFallbackFactory(file); } @PostMapping(value = "/upload-with-fallback") - public String uploadFileWithFallback(@RequestPart(value = "file") MultipartFile file) throws NotFoundException { + public String uploadFileWithFallback(@RequestPart(value = "file") MultipartFile file) { return service.uploadFileWithFallback(file); } diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java index 31b4e385ed..750d0ff201 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java @@ -4,8 +4,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; -import com.baeldung.cloud.openfeign.exception.NotFoundException; - import feign.Feign; import feign.Response; import feign.form.spring.SpringFormEncoder; @@ -26,11 +24,11 @@ public class UploadService { return response.status() == 200; } - public String uploadFileWithFallbackFactory(MultipartFile file) throws NotFoundException { + public String uploadFileWithFallbackFactory(MultipartFile file) { return fileUploadClient.fileUpload(file); } - public String uploadFileWithFallback(MultipartFile file) throws NotFoundException { + public String uploadFileWithFallback(MultipartFile file) { return fileUploadClientWithFallback.fileUpload(file); } } \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java index f558e07491..771660662e 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java @@ -33,7 +33,7 @@ public class OpenFeignFileUploadLiveTest { FileInputStream input = new FileInputStream(file); MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(input)); - Assert.assertTrue(uploadService.uploadFileWithManualClient(multipartFile)); + uploadService.uploadFileWithFallback(multipartFile); } @Test @@ -44,7 +44,6 @@ public class OpenFeignFileUploadLiveTest { FileInputStream input = new FileInputStream(file); MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(input)); - String uploadFile = uploadService.uploadFile(multipartFile); - Assert.assertNotNull(uploadFile); + uploadService.uploadFileWithFallbackFactory(multipartFile); } } From 4bae437bd6419f4678b4965ce27eee58446854d5 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 25 Jul 2022 17:16:48 +0530 Subject: [PATCH 14/35] Changes adding Live tests --- .../fileupload/controller/FileController.java | 27 +++---------------- .../service/FileUploadClientWithFallBack.java | 4 +-- .../FileUploadClientWithFallbackFactory.java | 4 +-- .../fileupload/service/UploadResource.java | 2 +- .../fileupload/service/UploadService.java | 2 +- .../OpenFeignFileUploadLiveTest.java | 22 +++++++++++---- 6 files changed, 27 insertions(+), 34 deletions(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java index 147c3f5498..abb71e82f9 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java @@ -1,37 +1,18 @@ package com.baeldung.cloud.openfeign.fileupload.controller; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import com.baeldung.cloud.openfeign.fileupload.service.UploadService; +import com.baeldung.cloud.openfeign.exception.NotFoundException; @RestController public class FileController { - @Autowired - private UploadService service; - - @PostMapping(value = "/upload-mannual-client") - public boolean handleFileUploadWithManualClient(@RequestPart(value = "file") MultipartFile file) { - return service.uploadFileWithManualClient(file); - } - - @PostMapping(value = "/upload-file") - public boolean handleFileUpload(@RequestPart(value = "file") MultipartFile file) { - return service.uploadFileWithManualClient(file); - } - - @PostMapping(value = "/upload-with-fallbackfactory") - public String uploadFileWithFallbackFactory(@RequestPart(value = "file") MultipartFile file) { - return service.uploadFileWithFallbackFactory(file); - } - - @PostMapping(value = "/upload-with-fallback") - public String uploadFileWithFallback(@RequestPart(value = "file") MultipartFile file) { - return service.uploadFileWithFallback(file); + @PostMapping(value = "/upload-error") + public String uploadFileWithFallback(@RequestPart(value = "file") MultipartFile file) throws NotFoundException { + throw new NotFoundException("Not Found!!!"); } } \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallBack.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallBack.java index a7ca3d6147..e842770f2d 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallBack.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallBack.java @@ -8,8 +8,8 @@ import org.springframework.web.multipart.MultipartFile; import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig; -@FeignClient(name = "file", url = "http://localhost:8080", configuration = FeignSupportConfig.class, fallback = FileUploadClientWithFallbackImpl.class) +@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class, fallback = FileUploadClientWithFallbackImpl.class) public interface FileUploadClientWithFallBack { - @PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @PostMapping(value = "/upload-error", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) String fileUpload(@RequestPart(value = "file") MultipartFile file); } diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackFactory.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackFactory.java index abf9892c19..829cd0f535 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackFactory.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientWithFallbackFactory.java @@ -8,8 +8,8 @@ import org.springframework.web.multipart.MultipartFile; import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig; -@FeignClient(name = "file", url = "http://localhost:8080", configuration = FeignSupportConfig.class, fallbackFactory = FileUploadClientFallbackFactory.class) +@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class, fallbackFactory = FileUploadClientFallbackFactory.class) public interface FileUploadClientWithFallbackFactory { - @PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @PostMapping(value = "/upload-error", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) String fileUpload(@RequestPart(value = "file") MultipartFile file); } diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadResource.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadResource.java index 26e658a7f0..2d5090897d 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadResource.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadResource.java @@ -9,7 +9,7 @@ import feign.Response; public interface UploadResource { - @RequestLine("POST /upload-file") + @RequestLine("POST /upload-error") @Headers("Content-Type: multipart/form-data") Response uploadFile(@Param("file") MultipartFile file); diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java index 750d0ff201..244a5a2168 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/UploadService.java @@ -10,7 +10,7 @@ import feign.form.spring.SpringFormEncoder; @Service public class UploadService { - private static final String HTTP_FILE_UPLOAD_URL = "http://localhost:8080"; + private static final String HTTP_FILE_UPLOAD_URL = "http://localhost:8081"; @Autowired private FileUploadClientWithFallbackFactory fileUploadClient; diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java index 771660662e..6396be2453 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java +++ b/spring-cloud-modules/spring-cloud-openfeign-2/src/test/java/com/baeldung/cloud/openfeign/OpenFeignFileUploadLiveTest.java @@ -14,6 +14,7 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.multipart.MultipartFile; +import com.baeldung.cloud.openfeign.exception.NotFoundException; import com.baeldung.cloud.openfeign.fileupload.service.UploadService; @RunWith(SpringRunner.class) @@ -25,8 +26,19 @@ public class OpenFeignFileUploadLiveTest { private static String FILE_NAME = "fileupload.txt"; - @Test - public void whenFeignBuilder_thenFileUploadSuccess() throws IOException { + @Test(expected = NotFoundException.class) + public void whenFileUploadClientFallbackFactory_thenFileUploadError() throws IOException { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + File file = new File(classloader.getResource(FILE_NAME).getFile()); + Assert.assertTrue(file.exists()); + FileInputStream input = new FileInputStream(file); + MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", + IOUtils.toByteArray(input)); + uploadService.uploadFileWithFallbackFactory(multipartFile); + } + + @Test(expected = NotFoundException.class) + public void whenFileUploadClientFallback_thenFileUploadError() throws IOException { ClassLoader classloader = Thread.currentThread().getContextClassLoader(); File file = new File(classloader.getResource(FILE_NAME).getFile()); Assert.assertTrue(file.exists()); @@ -36,14 +48,14 @@ public class OpenFeignFileUploadLiveTest { uploadService.uploadFileWithFallback(multipartFile); } - @Test - public void whenAnnotatedFeignClient_thenFileUploadSuccess() throws IOException { + @Test(expected = NotFoundException.class) + public void whenFileUploadWithMannualClient_thenFileUploadError() throws IOException { ClassLoader classloader = Thread.currentThread().getContextClassLoader(); File file = new File(classloader.getResource(FILE_NAME).getFile()); Assert.assertTrue(file.exists()); FileInputStream input = new FileInputStream(file); MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(input)); - uploadService.uploadFileWithFallbackFactory(multipartFile); + uploadService.uploadFileWithManualClient(multipartFile); } } From 0a31d589e49cd3325672e24577abea7b0dfd4d18 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Wed, 27 Jul 2022 17:42:04 +0530 Subject: [PATCH 15/35] Update pom.xml --- spring-cloud-modules/spring-cloud-openfeign-2/pom.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml b/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml index 1e968e5d00..55de22100c 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml +++ b/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml @@ -49,14 +49,6 @@ io.github.openfeign.form feign-form-spring - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.security - spring-security-oauth2-client - org.springframework.boot spring-boot-starter-test From 712c96c8b03bd0812f20095b1a46cbd8e2beeee2 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Wed, 27 Jul 2022 17:42:41 +0530 Subject: [PATCH 16/35] Update README.md --- spring-cloud-modules/spring-cloud-openfeign-2/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/README.md b/spring-cloud-modules/spring-cloud-openfeign-2/README.md index a4cd84bb2b..7d843af9ea 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/README.md +++ b/spring-cloud-modules/spring-cloud-openfeign-2/README.md @@ -1,3 +1 @@ ### Relevant Articles: - -- [Introduction to Spring Cloud OpenFeign](https://www.baeldung.com/spring-cloud-openfeign) From d7d78df6f66a2782b4c962098705772f9bdcf6da Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 5 Aug 2022 22:15:12 +0530 Subject: [PATCH 17/35] Update pom.xml --- spring-cloud-modules/spring-cloud-openfeign-2/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml b/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml index 55de22100c..7f7acc5fe8 100644 --- a/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml +++ b/spring-cloud-modules/spring-cloud-openfeign-2/pom.xml @@ -43,7 +43,7 @@ io.github.openfeign.form feign-form - 3.8.0 + ${feign-form.version} io.github.openfeign.form @@ -58,6 +58,7 @@ 2021.0.0 + 3.8.0 \ No newline at end of file From d8a58d8e0f3386d01de43ca86d093f3d27b08fd9 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 12 Aug 2022 11:14:38 +0530 Subject: [PATCH 18/35] Delete ClientConfiguration.java --- .../openfeign/config/ClientConfiguration.java | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/config/ClientConfiguration.java diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/config/ClientConfiguration.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/config/ClientConfiguration.java deleted file mode 100644 index 801bd6c729..0000000000 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/config/ClientConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.cloud.openfeign.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import feign.Logger; -import feign.codec.ErrorDecoder; - -@Configuration -public class ClientConfiguration { - - @Bean - public Logger.Level feignLoggerLevel() { - return Logger.Level.FULL; - } - - @Bean - public ErrorDecoder errorDecoder() { - return new ErrorDecoder.Default(); - } -} From 5c14183ac9a5bb2e6e0cbd6e58b33680ce098397 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 12 Aug 2022 11:18:29 +0530 Subject: [PATCH 19/35] Delete FileController.java --- .../fileupload/controller/FileController.java | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java diff --git a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java b/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java deleted file mode 100644 index abb71e82f9..0000000000 --- a/spring-cloud-modules/spring-cloud-openfeign-2/src/main/java/com/baeldung/cloud/openfeign/fileupload/controller/FileController.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.cloud.openfeign.fileupload.controller; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -import com.baeldung.cloud.openfeign.exception.NotFoundException; - -@RestController -public class FileController { - - @PostMapping(value = "/upload-error") - public String uploadFileWithFallback(@RequestPart(value = "file") MultipartFile file) throws NotFoundException { - throw new NotFoundException("Not Found!!!"); - } - -} \ No newline at end of file From 9ab0fc1fc5c1cfde1f4f7a8190625ea82faa1a7f Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Sun, 21 Aug 2022 17:52:10 +0530 Subject: [PATCH 20/35] Update pom.xml --- spring-cloud-modules/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud-modules/pom.xml b/spring-cloud-modules/pom.xml index e725b366c6..55de65aaef 100644 --- a/spring-cloud-modules/pom.xml +++ b/spring-cloud-modules/pom.xml @@ -53,6 +53,7 @@ spring-cloud-bus spring-cloud-data-flow spring-cloud-sleuth + spring-cloud-openfeign-2 From d7556fc543bf401968ab9396f0d72ae8ceabf7d1 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Fri, 26 Aug 2022 13:06:36 +0530 Subject: [PATCH 21/35] JAVA-11502 Fixed next and previous links of submodules of vavr-modules (#12651) --- vavr-modules/vavr-2/README.md | 2 +- vavr-modules/vavr/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vavr-modules/vavr-2/README.md b/vavr-modules/vavr-2/README.md index 71814a08fd..79f415d729 100644 --- a/vavr-modules/vavr-2/README.md +++ b/vavr-modules/vavr-2/README.md @@ -5,4 +5,4 @@ This module contains articles about Vavr. ### Relevant Articles: - [Introduction to Vavr’s Either](https://www.baeldung.com/vavr-either) - [Interoperability Between Java and Vavr](https://www.baeldung.com/java-vavr) -- [[<-- prev]](/vavr) +- [[<-- prev]](/vavr-modules/vavr) diff --git a/vavr-modules/vavr/README.md b/vavr-modules/vavr/README.md index e04e02069f..c288fb6028 100644 --- a/vavr-modules/vavr/README.md +++ b/vavr-modules/vavr/README.md @@ -13,4 +13,4 @@ This module contains articles about Vavr. - [Guide to Collections API in Vavr](https://www.baeldung.com/vavr-collections) - [Collection Factory Methods for Vavr](https://www.baeldung.com/vavr-collection-factory-methods) - [Introduction to Future in Vavr](https://www.baeldung.com/vavr-future) -- [[next -->]](/vavr-2) +- [[next -->]](/vavr-modules/vavr-2) From ec6499d944286229539c44e251bbef4e7f2235b0 Mon Sep 17 00:00:00 2001 From: panos-kakos <102670093+panos-kakos@users.noreply.github.com> Date: Fri, 26 Aug 2022 08:39:34 +0100 Subject: [PATCH 22/35] [JAVA-13942] Upgrade jmh-core and jmh-generator dependency at main pom.xml (#12623) Co-authored-by: panagiotiskakos --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8f4ac4d8de..f0a0e8e0d6 100644 --- a/pom.xml +++ b/pom.xml @@ -1302,8 +1302,8 @@ 1.8 1.2.17 2.5.0.0 - 1.33 - 1.33 + 1.35 + 1.35 2.21.0 4.4 2.11.0 From f8278e0f63ce22e5cdf61c113e385c74379b7adb Mon Sep 17 00:00:00 2001 From: Ulisses Lima Date: Fri, 26 Aug 2022 05:34:07 -0300 Subject: [PATCH 23/35] BAEL-5366 Spring Data MongoDB - Configure Connection (#12544) * moving SpringBootPersistenceApplication class to its own package * from com.baeldung to com.baeldung.logging to prevent it from loading contexts from other applications. * moving SpringBootPersistenceApplication class to its own package * from com.baeldung to com.baeldung.logging to prevent it from loading contexts from other applications. * Spring Data MongoDB - Configure Connection Ready for revision. * fixed tests to reflect article changes * BAEL-5657 * reverting BAEL-5657 * reverting BAEL-5657 --- .../SpringMongoConnectionViaBuilderApp.java | 31 +++ .../SpringMongoConnectionViaClientApp.java | 46 +++++ .../SpringMongoConnectionViaFactoryApp.java | 40 ++++ ...SpringMongoConnectionViaPropertiesApp.java | 22 +++ .../SpringBootPersistenceApplication.java | 2 +- .../connection.via.properties/app.properties | 5 + .../MongoConnectionApplicationLiveTest.java | 180 ++++++++++++++++++ 7 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/builder/SpringMongoConnectionViaBuilderApp.java create mode 100644 persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/client/SpringMongoConnectionViaClientApp.java create mode 100644 persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/factory/SpringMongoConnectionViaFactoryApp.java create mode 100644 persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/properties/SpringMongoConnectionViaPropertiesApp.java rename persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/{ => logging}/SpringBootPersistenceApplication.java (91%) create mode 100644 persistence-modules/spring-boot-persistence-mongodb-2/src/main/resources/connection.via.properties/app.properties create mode 100644 persistence-modules/spring-boot-persistence-mongodb-2/src/test/java/com/baeldung/boot/connection/via/tests/MongoConnectionApplicationLiveTest.java diff --git a/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/builder/SpringMongoConnectionViaBuilderApp.java b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/builder/SpringMongoConnectionViaBuilderApp.java new file mode 100644 index 0000000000..00a1166a48 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/builder/SpringMongoConnectionViaBuilderApp.java @@ -0,0 +1,31 @@ +package com.baeldung.boot.connection.via.builder; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.WebApplicationType; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.mongo.MongoClientSettingsBuilderCustomizer; +import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; + +import com.mongodb.ConnectionString; + +@EnableAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class) +@EnableMongoRepositories(basePackages = { "com.baeldung.boot.connection.base" }) +@SpringBootApplication(scanBasePackages = { "com.baeldung.boot.connection.base" }) +public class SpringMongoConnectionViaBuilderApp { + + public static void main(String... args) { + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaBuilderApp.class); + app.web(WebApplicationType.NONE); + app.run(args); + } + + @Bean + public MongoClientSettingsBuilderCustomizer customizer(@Value("${custom.uri}") String uri) { + ConnectionString connection = new ConnectionString(uri); + return settings -> settings.applyConnectionString(connection); + } +} diff --git a/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/client/SpringMongoConnectionViaClientApp.java b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/client/SpringMongoConnectionViaClientApp.java new file mode 100644 index 0000000000..6b86fcac2b --- /dev/null +++ b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/client/SpringMongoConnectionViaClientApp.java @@ -0,0 +1,46 @@ +package com.baeldung.boot.connection.via.client; + +import org.bson.Document; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.WebApplicationType; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; + +import com.mongodb.client.ListDatabasesIterable; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; + +@EnableAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class) +@EnableMongoRepositories(basePackages = { "com.baeldung.boot.connection.base" }) +@SpringBootApplication(scanBasePackages = { "com.baeldung.boot.connection.base" }) +public class SpringMongoConnectionViaClientApp extends AbstractMongoClientConfiguration { + + public static void main(String... args) { + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaClientApp.class); + app.web(WebApplicationType.NONE); + app.run(args); + } + + @Value("${spring.data.mongodb.uri}") + private String uri; + + @Value("${spring.data.mongodb.database}") + private String db; + + @Override + public MongoClient mongoClient() { + MongoClient client = MongoClients.create(uri); + ListDatabasesIterable databases = client.listDatabases(); + databases.forEach(System.out::println); + return client; + } + + @Override + protected String getDatabaseName() { + return db; + } +} diff --git a/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/factory/SpringMongoConnectionViaFactoryApp.java b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/factory/SpringMongoConnectionViaFactoryApp.java new file mode 100644 index 0000000000..7f7c3f0668 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/factory/SpringMongoConnectionViaFactoryApp.java @@ -0,0 +1,40 @@ +package com.baeldung.boot.connection.via.factory; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.WebApplicationType; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.data.mongodb.core.MongoClientFactoryBean; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; + +import com.mongodb.ConnectionString; +import com.mongodb.client.MongoClient; + +@EnableAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class) +@EnableMongoRepositories(basePackages = { "com.baeldung.boot.connection.base" }) +@SpringBootApplication(scanBasePackages = { "com.baeldung.boot.connection.base" }) +public class SpringMongoConnectionViaFactoryApp { + + public static void main(String... args) { + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaFactoryApp.class); + app.web(WebApplicationType.NONE); + app.run(args); + } + + @Bean + public MongoClientFactoryBean mongo(@Value("${custom.uri}") String uri) throws Exception { + MongoClientFactoryBean mongo = new MongoClientFactoryBean(); + ConnectionString conn = new ConnectionString(uri); + mongo.setConnectionString(conn); + + mongo.setSingleton(false); + + MongoClient client = mongo.getObject(); + client.listDatabaseNames() + .forEach(System.out::println); + return mongo; + } +} diff --git a/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/properties/SpringMongoConnectionViaPropertiesApp.java b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/properties/SpringMongoConnectionViaPropertiesApp.java new file mode 100644 index 0000000000..e6eb1dea33 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/boot/connection/via/properties/SpringMongoConnectionViaPropertiesApp.java @@ -0,0 +1,22 @@ +package com.baeldung.boot.connection.via.properties; + +import org.springframework.boot.WebApplicationType; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.annotation.PropertySource; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; + +@PropertySource("classpath:connection.via.properties/app.properties") +@EnableAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class) +@EnableMongoRepositories(basePackages = { "com.baeldung.boot.connection.base" }) +@SpringBootApplication(scanBasePackages = { "com.baeldung.boot.connection.base" }) +public class SpringMongoConnectionViaPropertiesApp { + + public static void main(String... args) { + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaPropertiesApp.class); + app.web(WebApplicationType.NONE); + app.run(args); + } +} diff --git a/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/SpringBootPersistenceApplication.java b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/logging/SpringBootPersistenceApplication.java similarity index 91% rename from persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/SpringBootPersistenceApplication.java rename to persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/logging/SpringBootPersistenceApplication.java index 2dff3f37df..bcca23b714 100644 --- a/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/SpringBootPersistenceApplication.java +++ b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/java/com/baeldung/logging/SpringBootPersistenceApplication.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.logging; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/persistence-modules/spring-boot-persistence-mongodb-2/src/main/resources/connection.via.properties/app.properties b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/resources/connection.via.properties/app.properties new file mode 100644 index 0000000000..6e5d8c3050 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-mongodb-2/src/main/resources/connection.via.properties/app.properties @@ -0,0 +1,5 @@ +spring.data.mongodb.database=baeldung +spring.data.mongodb.host=localhost +spring.data.mongodb.port=27017 +spring.data.mongodb.username=admin +spring.data.mongodb.password=password diff --git a/persistence-modules/spring-boot-persistence-mongodb-2/src/test/java/com/baeldung/boot/connection/via/tests/MongoConnectionApplicationLiveTest.java b/persistence-modules/spring-boot-persistence-mongodb-2/src/test/java/com/baeldung/boot/connection/via/tests/MongoConnectionApplicationLiveTest.java new file mode 100644 index 0000000000..a306232c8a --- /dev/null +++ b/persistence-modules/spring-boot-persistence-mongodb-2/src/test/java/com/baeldung/boot/connection/via/tests/MongoConnectionApplicationLiveTest.java @@ -0,0 +1,180 @@ +package com.baeldung.boot.connection.via.tests; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import org.bson.Document; +import org.junit.Before; +import org.junit.Test; +import org.springframework.beans.factory.BeanCreationException; +import org.springframework.boot.WebApplicationType; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.test.annotation.DirtiesContext; + +import com.baeldung.boot.connection.via.builder.SpringMongoConnectionViaBuilderApp; +import com.baeldung.boot.connection.via.client.SpringMongoConnectionViaClientApp; +import com.baeldung.boot.connection.via.factory.SpringMongoConnectionViaFactoryApp; +import com.baeldung.boot.connection.via.properties.SpringMongoConnectionViaPropertiesApp; + +@DirtiesContext +public class MongoConnectionApplicationLiveTest { + private static final String HOST = "localhost"; + private static final String PORT = "27017"; + private static final String DB = "baeldung"; + private static final String USER = "admin"; + private static final String PASS = "password"; + + private void assertInsertSucceeds(ConfigurableApplicationContext context) { + String name = "A"; + + MongoTemplate mongo = context.getBean(MongoTemplate.class); + Document doc = Document.parse("{\"name\":\"" + name + "\"}"); + Document inserted = mongo.insert(doc, "items"); + + assertNotNull(inserted.get("_id")); + assertEquals(inserted.get("name"), name); + } + + @Before + public void clearSystemProperties() { + System.clearProperty("spring.data.mongodb.host"); + System.clearProperty("spring.data.mongodb.port"); + System.clearProperty("spring.data.mongodb.database"); + System.clearProperty("spring.data.mongodb.username"); + System.clearProperty("spring.data.mongodb.password"); + System.clearProperty("spring.data.mongodb.uri"); + } + + @Test + public void whenPropertiesConfig_thenInsertSucceeds() { + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaPropertiesApp.class); + app.web(WebApplicationType.NONE) + .run(); + + assertInsertSucceeds(app.context()); + } + + @Test + public void whenSystemConfig_thenInsertSucceeds() { + System.setProperty("spring.data.mongodb.host", HOST); + System.setProperty("spring.data.mongodb.port", PORT); + System.setProperty("spring.data.mongodb.database", DB); + System.setProperty("spring.data.mongodb.username", USER); + System.setProperty("spring.data.mongodb.password", PASS); + + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaPropertiesApp.class); + app.web(WebApplicationType.NONE) + .run(); + + assertInsertSucceeds(app.context()); + } + + @Test + public void givenPrecedence_whenSystemConfig_thenInsertSucceeds() { + System.setProperty("spring.data.mongodb.host", HOST); + System.setProperty("spring.data.mongodb.port", PORT); + System.setProperty("spring.data.mongodb.database", DB); + System.setProperty("spring.data.mongodb.username", USER); + System.setProperty("spring.data.mongodb.password", PASS); + + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaPropertiesApp.class) + .properties( + "spring.data.mongodb.host=oldValue", + "spring.data.mongodb.port=oldValue", + "spring.data.mongodb.database=oldValue", + "spring.data.mongodb.username=oldValue", + "spring.data.mongodb.password=oldValue" + ); + + app.web(WebApplicationType.NONE) + .run(); + + assertInsertSucceeds(app.context()); + } + + @Test + public void givenPrecedence_whenApplicationArgs_thenInsertSucceeds() { + System.setProperty("spring.data.mongodb.host", "incorrect"); + System.setProperty("spring.data.mongodb.port", "incorrect"); + System.setProperty("spring.data.mongodb.database", "incorrect"); + System.setProperty("spring.data.mongodb.username", "incorrect"); + System.setProperty("spring.data.mongodb.password", "incorrect"); + + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaPropertiesApp.class); + app.web(WebApplicationType.NONE) + .run( + "--spring.data.mongodb.host=" + HOST, + "--spring.data.mongodb.port=" + PORT, + "--spring.data.mongodb.database=" + DB, + "--spring.data.mongodb.username=" + USER, + "--spring.data.mongodb.password=" + PASS + ); + + assertInsertSucceeds(app.context()); + } + + @Test + public void givenConnectionUri_whenAlsoIncludingIndividualParameters_thenInvalidConfig() { + System.setProperty( + "spring.data.mongodb.uri", + "mongodb://" + USER + ":" + PASS + "@" + HOST + ":" + PORT + "/" + DB + ); + + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaPropertiesApp.class) + .web(WebApplicationType.NONE) + .properties( + "spring.data.mongodb.host=" + HOST, + "spring.data.mongodb.port=" + PORT, + "spring.data.mongodb.username=" + USER, + "spring.data.mongodb.password=" + PASS + ); + + BeanCreationException e = assertThrows(BeanCreationException.class, () -> { + app.run(); + }); + + Throwable rootCause = e.getRootCause(); + assertTrue(rootCause instanceof IllegalStateException); + assertThat(rootCause.getMessage() + .contains("Invalid mongo configuration, either uri or host/port/credentials/replicaSet must be specified")); + } + + @Test + public void whenClientConfig_thenInsertSucceeds() { + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaClientApp.class); + app.web(WebApplicationType.NONE) + .run( + "--spring.data.mongodb.uri=mongodb://" + USER + ":" + PASS + "@" + HOST + ":" + PORT + "/" + DB, + "--spring.data.mongodb.database=" + DB + ); + + assertInsertSucceeds(app.context()); + } + + @Test + public void whenFactoryConfig_thenInsertSucceeds() { + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaFactoryApp.class); + app.web(WebApplicationType.NONE) + .run( + "--custom.uri=mongodb://" + USER + ":" + PASS + "@" + HOST + ":" + PORT + "/" + DB + ); + + assertInsertSucceeds(app.context()); + } + + @Test + public void whenBuilderConfig_thenInsertSucceeds() { + SpringApplicationBuilder app = new SpringApplicationBuilder(SpringMongoConnectionViaBuilderApp.class); + app.web(WebApplicationType.NONE) + .run( + "--custom.uri=mongodb://" + USER + ":" + PASS + "@" + HOST + ":" + PORT + "/" + DB + ); + + assertInsertSucceeds(app.context()); + } +} From eb24cfa8beaa2092e56e501eeb3863e99c1c4ca0 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Fri, 26 Aug 2022 09:47:08 +0100 Subject: [PATCH 24/35] [JAVA-13010] Convert file tests to manual tests (#12561) --- .../{FileClassUnitTest.java => FileClassManualTest.java} | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/{FileClassUnitTest.java => FileClassManualTest.java} (98%) diff --git a/core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/FileClassUnitTest.java b/core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/FileClassManualTest.java similarity index 98% rename from core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/FileClassUnitTest.java rename to core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/FileClassManualTest.java index 1883f40681..c5374f240e 100644 --- a/core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/FileClassUnitTest.java +++ b/core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/FileClassManualTest.java @@ -9,7 +9,10 @@ import java.util.List; import static org.junit.Assert.*; -public class FileClassUnitTest { +/** + * Manual tests for data reading and writing + */ +public class FileClassManualTest { @Test public void givenDir_whenMkdir_thenDirIsDeleted() { From 46499a24192d8a124741077c81cc91f8468249e8 Mon Sep 17 00:00:00 2001 From: freelansam <79205526+freelansam@users.noreply.github.com> Date: Fri, 26 Aug 2022 16:20:12 +0530 Subject: [PATCH 25/35] JAVA-13823: Review module names (#12628) * JAVA-13823: rename struts-2 to struts * JAVA-13823: rename spring-cloud-bus submodules * JAVA-13823: rename spring-cloud-config submodules * JAVA-13823: rename spring-cloud-data-flow submodules * JAVA-13823: rename spring-cloud-hystrix submodules * JAVA-13823: rename spring-cloud-netflix-sidecar submodules * JAVA-13823: rename spring-cloud-zookeeper submodules * JAVA-13823: rename spring-cloud-zuul-fallback submodules * JAVA-13823: rename spring-security-web-angular submodules Co-authored-by: Dhawal Kapil --- pom.xml | 2 + spring-cloud-modules/spring-cloud-bus/pom.xml | 4 +- .../pom.xml | 4 +- .../SpringCloudConfigClientApplication.java | 0 .../src/main/resources/application.yml | 0 .../src/main/resources/logback.xml | 0 .../com/baeldung/SpringContextLiveTest.java | 0 .../pom.xml | 4 +- .../SpringCloudConfigServerApplication.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/config-server.jks | Bin .../src/main/resources/logback.xml | 0 ...onfigServerApplicationIntegrationTest.java | 0 .../java/com/baeldung/SpringContextTest.java | 0 .../spring-cloud-config/pom.xml | 4 +- .../pom.xml | 4 +- .../cloud/config/client/ConfigClient.java | 0 .../src/main/resources/application.properties | 0 .../config/client/SpringContextLiveTest.java | 0 .../config-client-development.properties | 0 .../config-client-production.properties | 0 .../pom.xml | 4 +- .../cloud/config/server/ConfigServer.java | 0 .../config/server/SecurityConfiguration.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/config-server.jks | Bin .../config/server/SpringContextTest.java | 0 .../src/test/resources/application.properties | 0 .../spring-cloud-data-flow/pom.xml | 4 +- .../README.md | 0 .../pom.xml | 4 +- .../spring/cloud/PiApproximation.java | 0 .../README.md | 0 .../pom.xml | 4 +- .../spring/cloud/BatchJobApplication.java | 0 .../spring/cloud/JobConfiguration.java | 0 .../src/main/resources/logback.xml | 0 .../java/com/baeldung/SpringContextTest.java | 0 .../BatchJobApplicationIntegrationTest.java | 0 .../spring-cloud-hystrix/pom.xml | 6 +- .../pom.xml | 4 +- .../hystrix/rest/consumer/GreetingClient.java | 0 .../rest/consumer/GreetingController.java | 0 .../RestConsumerFeignApplication.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/logback.xml | 0 .../resources/templates/greeting-view.html | 0 .../rest/consumer/SpringContextTest.java | 0 .../pom.xml | 4 +- .../rest/consumer/GreetingController.java | 0 .../rest/consumer/GreetingService.java | 0 .../consumer/RestConsumerApplication.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/logback.xml | 0 .../resources/templates/greeting-view.html | 0 .../rest/consumer/SpringContextTest.java | 0 .../pom.xml | 4 +- .../rest/producer/GreetingController.java | 0 .../rest/producer/GreetingControllerImpl.java | 0 .../producer/RestProducerApplication.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/logback.xml | 0 .../rest/producer/SpringContextTest.java | 0 .../spring-cloud-netflix-sidecar/pom.xml | 4 +- .../nodejs/hello.js | 0 .../pom.xml | 4 +- .../cloud/sidecar/SidecarApplication.java | 0 .../src/main/resources/application.yml | 0 .../cloud/sidecar/SpringContextTest.java | 0 .../pom.xml | 4 +- .../baeldung/cloud/echo/EchoApplication.java | 0 .../src/main/resources/application.yml | 0 .../cloud/echo/SpringContextTest.java | 0 .../spring-cloud-zookeeper/pom.xml | 4 +- .../pom.xml | 4 +- .../cloud/greeting/GreetingApplication.java | 0 .../cloud/greeting/GreetingController.java | 0 .../cloud/greeting/HelloWorldClient.java | 0 .../src/main/resources/application.yml | 0 .../src/main/resources/logback.xml | 0 .../resources/templates/greeting-view.html | 0 .../java/com/baeldung/SpringContextTest.java | 0 .../pom.xml | 4 +- .../helloworld/HelloWorldApplication.java | 0 .../helloworld/HelloWorldController.java | 0 .../src/main/resources/application.yml | 0 .../src/main/resources/logback.xml | 0 .../cloud/helloworld/SpringContextTest.java | 0 .../spring-cloud-zuul-fallback/pom.xml | 4 +- .../pom.xml | 4 +- .../apigateway/ApiGatewayApplication.java | 0 .../fallback/GatewayClientResponse.java | 0 .../fallback/GatewayServiceFallback.java | 0 .../fallback/WeatherServiceFallback.java | 0 .../src/main/resources/application.yml | 0 .../ApiGatewayApplicationIntegrationTest.java | 0 .../GatewayServiceFallbackUnitTest.java | 0 .../WeatherServiceFallbackUnitTest.java | 0 .../src/test/resources/logback.xml | 0 .../pom.xml | 4 +- .../weatherservice/WeatherController.java | 0 .../WeatherServiceApplication.java | 0 .../src/main/resources/application.yml | 0 .../WeatherControllerIntegrationTest.java | 0 ...therServiceApplicationIntegrationTest.java | 0 .../spring-security-web-angular/pom.xml | 2 +- .../anguarjs/app.js | 0 .../anguarjs/home/home.controller.js | 0 .../anguarjs/home/home.view.html | 0 .../anguarjs/index.html | 0 .../anguarjs/login/login.controller.js | 0 .../anguarjs/login/login.view.html | 0 .../angular2/app.css | 0 .../angular2/app/app.component.html | 0 .../angular2/app/app.component.ts | 0 .../angular2/app/app.module.ts | 0 .../angular2/app/app.routing.ts | 0 .../angular2/app/home/home.component.html | 0 .../angular2/app/home/home.component.ts | 0 .../angular2/app/login/login.component.html | 0 .../angular2/app/login/login.component.ts | 0 .../angular2/app/main.ts | 0 .../angular2/index.html | 0 .../angular2/package.json | 0 .../angular2/systemjs.config.js | 0 .../angular2/tsconfig.json | 0 .../angular4/.angular-cli.json | 0 .../angular4/package.json | 0 .../angular4/src/app/app.component.html | 0 .../angular4/src/app/app.component.ts | 0 .../angular4/src/app/app.module.ts | 0 .../angular4/src/app/app.routing.ts | 0 .../angular4/src/app/home/home.component.html | 0 .../angular4/src/app/home/home.component.ts | 0 .../src/app/login/login.component.html | 0 .../angular4/src/app/login/login.component.ts | 0 .../angular4/src/index.html | 0 .../angular4/src/main.ts | 0 .../angular4/src/polyfills.ts | 0 .../angular4/src/styles.css | 0 .../angular4/src/tsconfig.app.json | 0 .../angular4/tsconfig.json | 0 .../angular4/tslint.json | 0 .../angular5/.angular-cli.json | 0 .../angular5/package.json | 0 .../angular5/src/app/app.component.html | 0 .../angular5/src/app/app.component.ts | 0 .../angular5/src/app/app.module.ts | 0 .../angular5/src/app/app.routing.ts | 0 .../angular5/src/app/home/home.component.html | 0 .../angular5/src/app/home/home.component.ts | 0 .../src/app/login/login.component.html | 0 .../angular5/src/app/login/login.component.ts | 0 .../angular5/src/index.html | 0 .../angular5/src/main.ts | 0 .../angular5/src/polyfills.ts | 0 .../angular5/src/styles.css | 0 .../angular5/src/tsconfig.app.json | 0 .../angular5/tsconfig.json | 0 .../angular5/tslint.json | 0 .../angular6/angular.json | 0 .../angular6/package.json | 0 .../angular6/src/app/app.component.html | 0 .../angular6/src/app/app.component.ts | 0 .../angular6/src/app/app.module.ts | 0 .../angular6/src/app/app.routing.ts | 0 .../angular6/src/app/home/home.component.html | 0 .../angular6/src/app/home/home.component.ts | 0 .../src/app/login/login.component.html | 0 .../angular6/src/app/login/login.component.ts | 0 .../angular6/src/index.html | 0 .../angular6/src/main.ts | 0 .../angular6/src/polyfills.ts | 0 .../angular6/src/styles.css | 0 .../angular6/src/tsconfig.app.json | 0 .../angular6/tsconfig.json | 0 .../angular6/tslint.json | 0 .../pom.xml | 4 +- .../SpringBootSecurityApplication.java | 0 .../config/BasicAuthConfiguration.java | 0 .../controller/UserController.java | 0 .../springbootsecurityrest/vo/User.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/logback.xml | 0 .../java/com/baeldung/SpringContextTest.java | 0 ...BasicAuthConfigurationIntegrationTest.java | 0 struts/README.md | 7 ++ struts/WebContent/WEB-INF/web.xml | 12 +++ struts/WebContent/input.jsp | 21 +++++ struts/WebContent/result.jsp | 11 +++ struts/pom.xml | 76 ++++++++++++++++++ .../java/com/baeldung/struts/CarAction.java | 37 +++++++++ .../baeldung/struts/CarMessageService.java | 18 +++++ struts/src/main/resources/logback.xml | 13 +++ .../baeldung/struts/test/CarActionTest.java | 29 +++++++ 195 files changed, 274 insertions(+), 48 deletions(-) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-client => spring-cloud-bus-client}/pom.xml (94%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-client => spring-cloud-bus-client}/src/main/java/com/baeldung/SpringCloudConfigClientApplication.java (100%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-client => spring-cloud-bus-client}/src/main/resources/application.yml (100%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-client => spring-cloud-bus-client}/src/main/resources/logback.xml (100%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-client => spring-cloud-bus-client}/src/test/java/com/baeldung/SpringContextLiveTest.java (100%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-server => spring-cloud-bus-server}/pom.xml (94%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-server => spring-cloud-bus-server}/src/main/java/com/baeldung/SpringCloudConfigServerApplication.java (100%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-server => spring-cloud-bus-server}/src/main/resources/application.properties (100%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-server => spring-cloud-bus-server}/src/main/resources/config-server.jks (100%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-server => spring-cloud-bus-server}/src/main/resources/logback.xml (100%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-server => spring-cloud-bus-server}/src/test/java/com/baeldung/SpringCloudConfigServerApplicationIntegrationTest.java (100%) rename spring-cloud-modules/spring-cloud-bus/{spring-cloud-config-server => spring-cloud-bus-server}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename spring-cloud-modules/spring-cloud-config/{client => spring-cloud-config-client}/pom.xml (92%) rename spring-cloud-modules/spring-cloud-config/{client => spring-cloud-config-client}/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java (100%) rename spring-cloud-modules/spring-cloud-config/{client => spring-cloud-config-client}/src/main/resources/application.properties (100%) rename spring-cloud-modules/spring-cloud-config/{client => spring-cloud-config-client}/src/test/java/com/baeldung/spring/cloud/config/client/SpringContextLiveTest.java (100%) rename spring-cloud-modules/spring-cloud-config/{config-repo => spring-cloud-config-repo}/config-client-development.properties (100%) rename spring-cloud-modules/spring-cloud-config/{config-repo => spring-cloud-config-repo}/config-client-production.properties (100%) rename spring-cloud-modules/spring-cloud-config/{server => spring-cloud-config-server}/pom.xml (93%) rename spring-cloud-modules/spring-cloud-config/{server => spring-cloud-config-server}/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java (100%) rename spring-cloud-modules/spring-cloud-config/{server => spring-cloud-config-server}/src/main/java/com/baeldung/spring/cloud/config/server/SecurityConfiguration.java (100%) rename spring-cloud-modules/spring-cloud-config/{server => spring-cloud-config-server}/src/main/resources/application.properties (100%) rename spring-cloud-modules/spring-cloud-config/{server => spring-cloud-config-server}/src/main/resources/config-server.jks (100%) rename spring-cloud-modules/spring-cloud-config/{server => spring-cloud-config-server}/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextTest.java (100%) rename spring-cloud-modules/spring-cloud-config/{server => spring-cloud-config-server}/src/test/resources/application.properties (100%) rename spring-cloud-modules/spring-cloud-data-flow/{apache-spark-job => spring-cloud-data-flow-apache-spark-job}/README.md (100%) rename spring-cloud-modules/spring-cloud-data-flow/{apache-spark-job => spring-cloud-data-flow-apache-spark-job}/pom.xml (90%) rename spring-cloud-modules/spring-cloud-data-flow/{apache-spark-job => spring-cloud-data-flow-apache-spark-job}/src/main/java/com/baeldung/spring/cloud/PiApproximation.java (100%) rename spring-cloud-modules/spring-cloud-data-flow/{batch-job => spring-cloud-data-flow-batch-job}/README.md (100%) rename spring-cloud-modules/spring-cloud-data-flow/{batch-job => spring-cloud-data-flow-batch-job}/pom.xml (93%) rename spring-cloud-modules/spring-cloud-data-flow/{batch-job => spring-cloud-data-flow-batch-job}/src/main/java/com/baeldung/spring/cloud/BatchJobApplication.java (100%) rename spring-cloud-modules/spring-cloud-data-flow/{batch-job => spring-cloud-data-flow-batch-job}/src/main/java/com/baeldung/spring/cloud/JobConfiguration.java (100%) rename spring-cloud-modules/spring-cloud-data-flow/{batch-job => spring-cloud-data-flow-batch-job}/src/main/resources/logback.xml (100%) rename spring-cloud-modules/spring-cloud-data-flow/{batch-job => spring-cloud-data-flow-batch-job}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename spring-cloud-modules/spring-cloud-data-flow/{batch-job => spring-cloud-data-flow-batch-job}/src/test/java/com/baeldung/spring/cloud/BatchJobApplicationIntegrationTest.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{feign-rest-consumer => spring-cloud-hystrix-feign-rest-consumer}/pom.xml (95%) rename spring-cloud-modules/spring-cloud-hystrix/{feign-rest-consumer => spring-cloud-hystrix-feign-rest-consumer}/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{feign-rest-consumer => spring-cloud-hystrix-feign-rest-consumer}/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingController.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{feign-rest-consumer => spring-cloud-hystrix-feign-rest-consumer}/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{feign-rest-consumer => spring-cloud-hystrix-feign-rest-consumer}/src/main/resources/application.properties (100%) rename spring-cloud-modules/spring-cloud-hystrix/{feign-rest-consumer => spring-cloud-hystrix-feign-rest-consumer}/src/main/resources/logback.xml (100%) rename spring-cloud-modules/spring-cloud-hystrix/{feign-rest-consumer => spring-cloud-hystrix-feign-rest-consumer}/src/main/resources/templates/greeting-view.html (100%) rename spring-cloud-modules/spring-cloud-hystrix/{feign-rest-consumer => spring-cloud-hystrix-feign-rest-consumer}/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-consumer => spring-cloud-hystrix-rest-consumer}/pom.xml (95%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-consumer => spring-cloud-hystrix-rest-consumer}/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingController.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-consumer => spring-cloud-hystrix-rest-consumer}/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-consumer => spring-cloud-hystrix-rest-consumer}/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-consumer => spring-cloud-hystrix-rest-consumer}/src/main/resources/application.properties (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-consumer => spring-cloud-hystrix-rest-consumer}/src/main/resources/logback.xml (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-consumer => spring-cloud-hystrix-rest-consumer}/src/main/resources/templates/greeting-view.html (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-consumer => spring-cloud-hystrix-rest-consumer}/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-producer => spring-cloud-hystrix-rest-producer}/pom.xml (90%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-producer => spring-cloud-hystrix-rest-producer}/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-producer => spring-cloud-hystrix-rest-producer}/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingControllerImpl.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-producer => spring-cloud-hystrix-rest-producer}/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-producer => spring-cloud-hystrix-rest-producer}/src/main/resources/application.properties (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-producer => spring-cloud-hystrix-rest-producer}/src/main/resources/logback.xml (100%) rename spring-cloud-modules/spring-cloud-hystrix/{rest-producer => spring-cloud-hystrix-rest-producer}/src/test/java/com/baeldung/spring/cloud/hystrix/rest/producer/SpringContextTest.java (100%) rename spring-cloud-modules/spring-cloud-netflix-sidecar/{sidecar-demo => spring-cloud-netflix-sidecar-demo}/nodejs/hello.js (100%) rename spring-cloud-modules/spring-cloud-netflix-sidecar/{sidecar-demo => spring-cloud-netflix-sidecar-demo}/pom.xml (94%) rename spring-cloud-modules/spring-cloud-netflix-sidecar/{sidecar-demo => spring-cloud-netflix-sidecar-demo}/src/main/java/com/baeldung/cloud/sidecar/SidecarApplication.java (100%) rename spring-cloud-modules/spring-cloud-netflix-sidecar/{sidecar-demo => spring-cloud-netflix-sidecar-demo}/src/main/resources/application.yml (100%) rename spring-cloud-modules/spring-cloud-netflix-sidecar/{sidecar-demo => spring-cloud-netflix-sidecar-demo}/src/test/java/com/baeldung/cloud/sidecar/SpringContextTest.java (100%) rename spring-cloud-modules/spring-cloud-netflix-sidecar/{echo-demo => spring-cloud-netflix-sidecar-echo-demo}/pom.xml (93%) rename spring-cloud-modules/spring-cloud-netflix-sidecar/{echo-demo => spring-cloud-netflix-sidecar-echo-demo}/src/main/java/com/baeldung/cloud/echo/EchoApplication.java (100%) rename spring-cloud-modules/spring-cloud-netflix-sidecar/{echo-demo => spring-cloud-netflix-sidecar-echo-demo}/src/main/resources/application.yml (100%) rename spring-cloud-modules/spring-cloud-netflix-sidecar/{echo-demo => spring-cloud-netflix-sidecar-echo-demo}/src/test/java/com/baeldung/cloud/echo/SpringContextTest.java (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{Greeting => spring-cloud-zookeeper-greeting}/pom.xml (96%) rename spring-cloud-modules/spring-cloud-zookeeper/{Greeting => spring-cloud-zookeeper-greeting}/src/main/java/com/baeldung/spring/cloud/greeting/GreetingApplication.java (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{Greeting => spring-cloud-zookeeper-greeting}/src/main/java/com/baeldung/spring/cloud/greeting/GreetingController.java (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{Greeting => spring-cloud-zookeeper-greeting}/src/main/java/com/baeldung/spring/cloud/greeting/HelloWorldClient.java (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{Greeting => spring-cloud-zookeeper-greeting}/src/main/resources/application.yml (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{Greeting => spring-cloud-zookeeper-greeting}/src/main/resources/logback.xml (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{Greeting => spring-cloud-zookeeper-greeting}/src/main/resources/templates/greeting-view.html (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{Greeting => spring-cloud-zookeeper-greeting}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{HelloWorld => spring-cloud-zookeeper-helloworld}/pom.xml (95%) rename spring-cloud-modules/spring-cloud-zookeeper/{HelloWorld => spring-cloud-zookeeper-helloworld}/src/main/java/com/baeldung/spring/cloud/helloworld/HelloWorldApplication.java (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{HelloWorld => spring-cloud-zookeeper-helloworld}/src/main/java/com/baeldung/spring/cloud/helloworld/HelloWorldController.java (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{HelloWorld => spring-cloud-zookeeper-helloworld}/src/main/resources/application.yml (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{HelloWorld => spring-cloud-zookeeper-helloworld}/src/main/resources/logback.xml (100%) rename spring-cloud-modules/spring-cloud-zookeeper/{HelloWorld => spring-cloud-zookeeper-helloworld}/src/test/java/com/baeldung/spring/cloud/helloworld/SpringContextTest.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{api-gateway => spring-cloud-zuul-fallback-api-gateway}/pom.xml (93%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{api-gateway => spring-cloud-zuul-fallback-api-gateway}/src/main/java/com/baeldung/spring/cloud/apigateway/ApiGatewayApplication.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{api-gateway => spring-cloud-zuul-fallback-api-gateway}/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayClientResponse.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{api-gateway => spring-cloud-zuul-fallback-api-gateway}/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayServiceFallback.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{api-gateway => spring-cloud-zuul-fallback-api-gateway}/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/WeatherServiceFallback.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{api-gateway => spring-cloud-zuul-fallback-api-gateway}/src/main/resources/application.yml (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{api-gateway => spring-cloud-zuul-fallback-api-gateway}/src/test/java/com/baeldung/spring/cloud/apigateway/ApiGatewayApplicationIntegrationTest.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{api-gateway => spring-cloud-zuul-fallback-api-gateway}/src/test/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayServiceFallbackUnitTest.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{api-gateway => spring-cloud-zuul-fallback-api-gateway}/src/test/java/com/baeldung/spring/cloud/apigateway/fallback/WeatherServiceFallbackUnitTest.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{api-gateway => spring-cloud-zuul-fallback-api-gateway}/src/test/resources/logback.xml (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{weather-service => spring-cloud-zuul-fallback-weather-service}/pom.xml (92%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{weather-service => spring-cloud-zuul-fallback-weather-service}/src/main/java/com/baeldung/spring/cloud/weatherservice/WeatherController.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{weather-service => spring-cloud-zuul-fallback-weather-service}/src/main/java/com/baeldung/spring/cloud/weatherservice/WeatherServiceApplication.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{weather-service => spring-cloud-zuul-fallback-weather-service}/src/main/resources/application.yml (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{weather-service => spring-cloud-zuul-fallback-weather-service}/src/test/java/com/baeldung/spring/cloud/weatherservice/WeatherControllerIntegrationTest.java (100%) rename spring-cloud-modules/spring-cloud-zuul-fallback/{weather-service => spring-cloud-zuul-fallback-weather-service}/src/test/java/com/baeldung/spring/cloud/weatherservice/WeatherServiceApplicationIntegrationTest.java (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/anguarjs/app.js (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/anguarjs/home/home.controller.js (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/anguarjs/home/home.view.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/anguarjs/index.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/anguarjs/login/login.controller.js (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/anguarjs/login/login.view.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/app.css (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/app/app.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/app/app.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/app/app.module.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/app/app.routing.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/app/home/home.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/app/home/home.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/app/login/login.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/app/login/login.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/app/main.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/index.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/package.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/systemjs.config.js (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular2/tsconfig.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/.angular-cli.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/package.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/app/app.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/app/app.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/app/app.module.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/app/app.routing.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/app/home/home.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/app/home/home.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/app/login/login.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/app/login/login.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/index.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/main.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/polyfills.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/styles.css (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/src/tsconfig.app.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/tsconfig.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular4/tslint.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/.angular-cli.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/package.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/app/app.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/app/app.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/app/app.module.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/app/app.routing.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/app/home/home.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/app/home/home.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/app/login/login.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/app/login/login.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/index.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/main.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/polyfills.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/styles.css (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/src/tsconfig.app.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/tsconfig.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular5/tslint.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/angular.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/package.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/app/app.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/app/app.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/app/app.module.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/app/app.routing.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/app/home/home.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/app/home/home.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/app/login/login.component.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/app/login/login.component.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/index.html (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/main.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/polyfills.ts (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/styles.css (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/src/tsconfig.app.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/tsconfig.json (100%) rename spring-security-modules/spring-security-web-angular/{client => spring-security-web-angular-client}/angular6/tslint.json (100%) rename spring-security-modules/spring-security-web-angular/{server => spring-security-web-angular-server}/pom.xml (95%) rename spring-security-modules/spring-security-web-angular/{server => spring-security-web-angular-server}/src/main/java/com/baeldung/springbootsecurityrest/basicauth/SpringBootSecurityApplication.java (100%) rename spring-security-modules/spring-security-web-angular/{server => spring-security-web-angular-server}/src/main/java/com/baeldung/springbootsecurityrest/basicauth/config/BasicAuthConfiguration.java (100%) rename spring-security-modules/spring-security-web-angular/{server => spring-security-web-angular-server}/src/main/java/com/baeldung/springbootsecurityrest/controller/UserController.java (100%) rename spring-security-modules/spring-security-web-angular/{server => spring-security-web-angular-server}/src/main/java/com/baeldung/springbootsecurityrest/vo/User.java (100%) rename spring-security-modules/spring-security-web-angular/{server => spring-security-web-angular-server}/src/main/resources/application.properties (100%) rename spring-security-modules/spring-security-web-angular/{server => spring-security-web-angular-server}/src/main/resources/logback.xml (100%) rename spring-security-modules/spring-security-web-angular/{server => spring-security-web-angular-server}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename spring-security-modules/spring-security-web-angular/{server => spring-security-web-angular-server}/src/test/java/com/baeldung/springbootsecurityrest/BasicAuthConfigurationIntegrationTest.java (100%) create mode 100644 struts/README.md create mode 100644 struts/WebContent/WEB-INF/web.xml create mode 100644 struts/WebContent/input.jsp create mode 100644 struts/WebContent/result.jsp create mode 100644 struts/pom.xml create mode 100644 struts/src/main/java/com/baeldung/struts/CarAction.java create mode 100644 struts/src/main/java/com/baeldung/struts/CarMessageService.java create mode 100644 struts/src/main/resources/logback.xml create mode 100644 struts/src/test/java/com/baeldung/struts/test/CarActionTest.java diff --git a/pom.xml b/pom.xml index f0a0e8e0d6..0fb651ed34 100644 --- a/pom.xml +++ b/pom.xml @@ -617,6 +617,7 @@ static-analysis stripe + struts tensorflow-java testing-modules @@ -1008,6 +1009,7 @@ static-analysis stripe + struts tensorflow-java testing-modules diff --git a/spring-cloud-modules/spring-cloud-bus/pom.xml b/spring-cloud-modules/spring-cloud-bus/pom.xml index 4be1a60062..514060a400 100644 --- a/spring-cloud-modules/spring-cloud-bus/pom.xml +++ b/spring-cloud-modules/spring-cloud-bus/pom.xml @@ -16,8 +16,8 @@ - spring-cloud-config-client - spring-cloud-config-server + spring-cloud-bus-client + spring-cloud-bus-server diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/pom.xml b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/pom.xml similarity index 94% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/pom.xml rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/pom.xml index 87889570a3..0c6212c877 100644 --- a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/pom.xml +++ b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/pom.xml @@ -3,8 +3,8 @@ 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"> 4.0.0 - spring-cloud-config-client - spring-cloud-config-client + spring-cloud-bus-client + spring-cloud-bus-client jar Demo Spring Cloud Config Client diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/src/main/java/com/baeldung/SpringCloudConfigClientApplication.java b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/src/main/java/com/baeldung/SpringCloudConfigClientApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/src/main/java/com/baeldung/SpringCloudConfigClientApplication.java rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/src/main/java/com/baeldung/SpringCloudConfigClientApplication.java diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/src/main/resources/application.yml b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/src/main/resources/application.yml similarity index 100% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/src/main/resources/application.yml rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/src/main/resources/application.yml diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/src/main/resources/logback.xml b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/src/main/resources/logback.xml similarity index 100% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/src/main/resources/logback.xml rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/src/main/resources/logback.xml diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/src/test/java/com/baeldung/SpringContextLiveTest.java b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/src/test/java/com/baeldung/SpringContextLiveTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-client/src/test/java/com/baeldung/SpringContextLiveTest.java rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-client/src/test/java/com/baeldung/SpringContextLiveTest.java diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/pom.xml b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/pom.xml similarity index 94% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/pom.xml rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/pom.xml index e6439fa56a..18c758a2e1 100644 --- a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/pom.xml +++ b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/pom.xml @@ -3,8 +3,8 @@ 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"> 4.0.0 - spring-cloud-config-server - spring-cloud-config-server + spring-cloud-bus-server + spring-cloud-bus-server jar Demo Spring Cloud Config Server diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/main/java/com/baeldung/SpringCloudConfigServerApplication.java b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/main/java/com/baeldung/SpringCloudConfigServerApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/main/java/com/baeldung/SpringCloudConfigServerApplication.java rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/main/java/com/baeldung/SpringCloudConfigServerApplication.java diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/main/resources/application.properties b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/main/resources/application.properties similarity index 100% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/main/resources/application.properties rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/main/resources/application.properties diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/main/resources/config-server.jks b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/main/resources/config-server.jks similarity index 100% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/main/resources/config-server.jks rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/main/resources/config-server.jks diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/main/resources/logback.xml b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/main/resources/logback.xml similarity index 100% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/main/resources/logback.xml rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/main/resources/logback.xml diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/test/java/com/baeldung/SpringCloudConfigServerApplicationIntegrationTest.java b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/test/java/com/baeldung/SpringCloudConfigServerApplicationIntegrationTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/test/java/com/baeldung/SpringCloudConfigServerApplicationIntegrationTest.java rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/test/java/com/baeldung/SpringCloudConfigServerApplicationIntegrationTest.java diff --git a/spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/test/java/com/baeldung/SpringContextTest.java b/spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-bus/spring-cloud-config-server/src/test/java/com/baeldung/SpringContextTest.java rename to spring-cloud-modules/spring-cloud-bus/spring-cloud-bus-server/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-config/pom.xml b/spring-cloud-modules/spring-cloud-config/pom.xml index fc9a989844..965f65f61b 100644 --- a/spring-cloud-modules/spring-cloud-config/pom.xml +++ b/spring-cloud-modules/spring-cloud-config/pom.xml @@ -16,8 +16,8 @@ - server - client + spring-cloud-config-server + spring-cloud-config-client diff --git a/spring-cloud-modules/spring-cloud-config/client/pom.xml b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-client/pom.xml similarity index 92% rename from spring-cloud-modules/spring-cloud-config/client/pom.xml rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-client/pom.xml index 0f463b6d6d..5b7ff9640d 100644 --- a/spring-cloud-modules/spring-cloud-config/client/pom.xml +++ b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-client/pom.xml @@ -3,8 +3,8 @@ xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - client - client + spring-cloud-config-client + spring-cloud-config-client com.baeldung.spring.cloud diff --git a/spring-cloud-modules/spring-cloud-config/client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java similarity index 100% rename from spring-cloud-modules/spring-cloud-config/client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java diff --git a/spring-cloud-modules/spring-cloud-config/client/src/main/resources/application.properties b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-client/src/main/resources/application.properties similarity index 100% rename from spring-cloud-modules/spring-cloud-config/client/src/main/resources/application.properties rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-client/src/main/resources/application.properties diff --git a/spring-cloud-modules/spring-cloud-config/client/src/test/java/com/baeldung/spring/cloud/config/client/SpringContextLiveTest.java b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-client/src/test/java/com/baeldung/spring/cloud/config/client/SpringContextLiveTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-config/client/src/test/java/com/baeldung/spring/cloud/config/client/SpringContextLiveTest.java rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-client/src/test/java/com/baeldung/spring/cloud/config/client/SpringContextLiveTest.java diff --git a/spring-cloud-modules/spring-cloud-config/config-repo/config-client-development.properties b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-repo/config-client-development.properties similarity index 100% rename from spring-cloud-modules/spring-cloud-config/config-repo/config-client-development.properties rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-repo/config-client-development.properties diff --git a/spring-cloud-modules/spring-cloud-config/config-repo/config-client-production.properties b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-repo/config-client-production.properties similarity index 100% rename from spring-cloud-modules/spring-cloud-config/config-repo/config-client-production.properties rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-repo/config-client-production.properties diff --git a/spring-cloud-modules/spring-cloud-config/server/pom.xml b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/pom.xml similarity index 93% rename from spring-cloud-modules/spring-cloud-config/server/pom.xml rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/pom.xml index b41277113f..8920744a45 100644 --- a/spring-cloud-modules/spring-cloud-config/server/pom.xml +++ b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/pom.xml @@ -3,8 +3,8 @@ xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - server - server + spring-cloud-config-server + spring-cloud-config-server com.baeldung.spring.cloud diff --git a/spring-cloud-modules/spring-cloud-config/server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java similarity index 100% rename from spring-cloud-modules/spring-cloud-config/server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java diff --git a/spring-cloud-modules/spring-cloud-config/server/src/main/java/com/baeldung/spring/cloud/config/server/SecurityConfiguration.java b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/main/java/com/baeldung/spring/cloud/config/server/SecurityConfiguration.java similarity index 100% rename from spring-cloud-modules/spring-cloud-config/server/src/main/java/com/baeldung/spring/cloud/config/server/SecurityConfiguration.java rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/main/java/com/baeldung/spring/cloud/config/server/SecurityConfiguration.java diff --git a/spring-cloud-modules/spring-cloud-config/server/src/main/resources/application.properties b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/main/resources/application.properties similarity index 100% rename from spring-cloud-modules/spring-cloud-config/server/src/main/resources/application.properties rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/main/resources/application.properties diff --git a/spring-cloud-modules/spring-cloud-config/server/src/main/resources/config-server.jks b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/main/resources/config-server.jks similarity index 100% rename from spring-cloud-modules/spring-cloud-config/server/src/main/resources/config-server.jks rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/main/resources/config-server.jks diff --git a/spring-cloud-modules/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextTest.java b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextTest.java rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-config/server/src/test/resources/application.properties b/spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/test/resources/application.properties similarity index 100% rename from spring-cloud-modules/spring-cloud-config/server/src/test/resources/application.properties rename to spring-cloud-modules/spring-cloud-config/spring-cloud-config-server/src/test/resources/application.properties diff --git a/spring-cloud-modules/spring-cloud-data-flow/pom.xml b/spring-cloud-modules/spring-cloud-data-flow/pom.xml index 25a70642ec..a9d9a22a84 100644 --- a/spring-cloud-modules/spring-cloud-data-flow/pom.xml +++ b/spring-cloud-modules/spring-cloud-data-flow/pom.xml @@ -17,8 +17,8 @@ spring-cloud-data-flow-stream-processing spring-cloud-data-flow-etl - batch-job - apache-spark-job + spring-cloud-data-flow-batch-job + spring-cloud-data-flow-apache-spark-job \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-data-flow/apache-spark-job/README.md b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-apache-spark-job/README.md similarity index 100% rename from spring-cloud-modules/spring-cloud-data-flow/apache-spark-job/README.md rename to spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-apache-spark-job/README.md diff --git a/spring-cloud-modules/spring-cloud-data-flow/apache-spark-job/pom.xml b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-apache-spark-job/pom.xml similarity index 90% rename from spring-cloud-modules/spring-cloud-data-flow/apache-spark-job/pom.xml rename to spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-apache-spark-job/pom.xml index b2b0c7d68a..b619cb43d0 100644 --- a/spring-cloud-modules/spring-cloud-data-flow/apache-spark-job/pom.xml +++ b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-apache-spark-job/pom.xml @@ -3,8 +3,8 @@ 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"> 4.0.0 - apache-spark-job - apache-spark-job + spring-cloud-data-flow-apache-spark-job + spring-cloud-data-flow-apache-spark-job com.baeldung.spring.cloud diff --git a/spring-cloud-modules/spring-cloud-data-flow/apache-spark-job/src/main/java/com/baeldung/spring/cloud/PiApproximation.java b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-apache-spark-job/src/main/java/com/baeldung/spring/cloud/PiApproximation.java similarity index 100% rename from spring-cloud-modules/spring-cloud-data-flow/apache-spark-job/src/main/java/com/baeldung/spring/cloud/PiApproximation.java rename to spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-apache-spark-job/src/main/java/com/baeldung/spring/cloud/PiApproximation.java diff --git a/spring-cloud-modules/spring-cloud-data-flow/batch-job/README.md b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/README.md similarity index 100% rename from spring-cloud-modules/spring-cloud-data-flow/batch-job/README.md rename to spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/README.md diff --git a/spring-cloud-modules/spring-cloud-data-flow/batch-job/pom.xml b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/pom.xml similarity index 93% rename from spring-cloud-modules/spring-cloud-data-flow/batch-job/pom.xml rename to spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/pom.xml index 627724a6be..1c877da946 100644 --- a/spring-cloud-modules/spring-cloud-data-flow/batch-job/pom.xml +++ b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/pom.xml @@ -4,9 +4,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.baeldung.spring.cloud - batch-job + spring-cloud-data-flow-batch-job 0.0.1-SNAPSHOT - batch-job + spring-cloud-data-flow-batch-job jar Demo project for Spring Boot diff --git a/spring-cloud-modules/spring-cloud-data-flow/batch-job/src/main/java/com/baeldung/spring/cloud/BatchJobApplication.java b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/src/main/java/com/baeldung/spring/cloud/BatchJobApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-data-flow/batch-job/src/main/java/com/baeldung/spring/cloud/BatchJobApplication.java rename to spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/src/main/java/com/baeldung/spring/cloud/BatchJobApplication.java diff --git a/spring-cloud-modules/spring-cloud-data-flow/batch-job/src/main/java/com/baeldung/spring/cloud/JobConfiguration.java b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/src/main/java/com/baeldung/spring/cloud/JobConfiguration.java similarity index 100% rename from spring-cloud-modules/spring-cloud-data-flow/batch-job/src/main/java/com/baeldung/spring/cloud/JobConfiguration.java rename to spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/src/main/java/com/baeldung/spring/cloud/JobConfiguration.java diff --git a/spring-cloud-modules/spring-cloud-data-flow/batch-job/src/main/resources/logback.xml b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/src/main/resources/logback.xml similarity index 100% rename from spring-cloud-modules/spring-cloud-data-flow/batch-job/src/main/resources/logback.xml rename to spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/src/main/resources/logback.xml diff --git a/spring-cloud-modules/spring-cloud-data-flow/batch-job/src/test/java/com/baeldung/SpringContextTest.java b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-data-flow/batch-job/src/test/java/com/baeldung/SpringContextTest.java rename to spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-data-flow/batch-job/src/test/java/com/baeldung/spring/cloud/BatchJobApplicationIntegrationTest.java b/spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/src/test/java/com/baeldung/spring/cloud/BatchJobApplicationIntegrationTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-data-flow/batch-job/src/test/java/com/baeldung/spring/cloud/BatchJobApplicationIntegrationTest.java rename to spring-cloud-modules/spring-cloud-data-flow/spring-cloud-data-flow-batch-job/src/test/java/com/baeldung/spring/cloud/BatchJobApplicationIntegrationTest.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/pom.xml b/spring-cloud-modules/spring-cloud-hystrix/pom.xml index 41548ba36a..804faf552f 100644 --- a/spring-cloud-modules/spring-cloud-hystrix/pom.xml +++ b/spring-cloud-modules/spring-cloud-hystrix/pom.xml @@ -15,9 +15,9 @@ - feign-rest-consumer - rest-producer - rest-consumer + spring-cloud-hystrix-feign-rest-consumer + spring-cloud-hystrix-rest-producer + spring-cloud-hystrix-rest-consumer \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/pom.xml b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml similarity index 95% rename from spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/pom.xml rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml index b57ef7f7d3..ec9bffea98 100644 --- a/spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/pom.xml +++ b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml @@ -3,9 +3,9 @@ xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - feign-rest-consumer + spring-cloud-hystrix-feign-rest-consumer 1.0.0-SNAPSHOT - feign-rest-consumer + spring-cloud-hystrix-feign-rest-consumer jar diff --git a/spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingController.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingController.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingController.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingController.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/resources/application.properties b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/resources/application.properties rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties diff --git a/spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/resources/logback.xml b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/logback.xml similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/resources/logback.xml rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/logback.xml diff --git a/spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/resources/templates/greeting-view.html b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/main/resources/templates/greeting-view.html rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html diff --git a/spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/feign-rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-consumer/pom.xml b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml similarity index 95% rename from spring-cloud-modules/spring-cloud-hystrix/rest-consumer/pom.xml rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml index 741457529c..3c9d6cdf59 100644 --- a/spring-cloud-modules/spring-cloud-hystrix/rest-consumer/pom.xml +++ b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml @@ -3,9 +3,9 @@ xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - rest-consumer + spring-cloud-hystrix-rest-consumer 1.0.0-SNAPSHOT - rest-consumer + spring-cloud-hystrix-rest-consumer jar diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingController.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingController.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingController.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingController.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/resources/application.properties b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/resources/application.properties rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/resources/logback.xml b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/logback.xml similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/resources/logback.xml rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/logback.xml diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/resources/templates/greeting-view.html b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/main/resources/templates/greeting-view.html rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-producer/pom.xml b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml similarity index 90% rename from spring-cloud-modules/spring-cloud-hystrix/rest-producer/pom.xml rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml index 8c72b34f87..cd9b8ab0ca 100644 --- a/spring-cloud-modules/spring-cloud-hystrix/rest-producer/pom.xml +++ b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml @@ -3,9 +3,9 @@ xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - rest-producer + spring-cloud-hystrix-rest-producer 1.0.0-SNAPSHOT - rest-producer + spring-cloud-hystrix-rest-producer jar diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingControllerImpl.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingControllerImpl.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingControllerImpl.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingControllerImpl.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/main/resources/application.properties b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/main/resources/application.properties rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/main/resources/logback.xml b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/logback.xml similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/main/resources/logback.xml rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/logback.xml diff --git a/spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/producer/SpringContextTest.java b/spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/producer/SpringContextTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-hystrix/rest-producer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/producer/SpringContextTest.java rename to spring-cloud-modules/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/producer/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-netflix-sidecar/pom.xml b/spring-cloud-modules/spring-cloud-netflix-sidecar/pom.xml index 3a72496279..919be24a35 100644 --- a/spring-cloud-modules/spring-cloud-netflix-sidecar/pom.xml +++ b/spring-cloud-modules/spring-cloud-netflix-sidecar/pom.xml @@ -17,8 +17,8 @@ - sidecar-demo - echo-demo + spring-cloud-netflix-sidecar-demo + spring-cloud-netflix-sidecar-echo-demo diff --git a/spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/nodejs/hello.js b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/nodejs/hello.js similarity index 100% rename from spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/nodejs/hello.js rename to spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/nodejs/hello.js diff --git a/spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/pom.xml b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/pom.xml similarity index 94% rename from spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/pom.xml rename to spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/pom.xml index 200897652f..f8552aba93 100644 --- a/spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/pom.xml +++ b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - sidecar-demo - sidecar-demo + spring-cloud-netflix-sidecar-demo + spring-cloud-netflix-sidecar-demo Sidecar demo for hello endpoint diff --git a/spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/src/main/java/com/baeldung/cloud/sidecar/SidecarApplication.java b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/src/main/java/com/baeldung/cloud/sidecar/SidecarApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/src/main/java/com/baeldung/cloud/sidecar/SidecarApplication.java rename to spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/src/main/java/com/baeldung/cloud/sidecar/SidecarApplication.java diff --git a/spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/src/main/resources/application.yml b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/src/main/resources/application.yml similarity index 100% rename from spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/src/main/resources/application.yml rename to spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/src/main/resources/application.yml diff --git a/spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/src/test/java/com/baeldung/cloud/sidecar/SpringContextTest.java b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/src/test/java/com/baeldung/cloud/sidecar/SpringContextTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-netflix-sidecar/sidecar-demo/src/test/java/com/baeldung/cloud/sidecar/SpringContextTest.java rename to spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-demo/src/test/java/com/baeldung/cloud/sidecar/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-netflix-sidecar/echo-demo/pom.xml b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-echo-demo/pom.xml similarity index 93% rename from spring-cloud-modules/spring-cloud-netflix-sidecar/echo-demo/pom.xml rename to spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-echo-demo/pom.xml index d8b1654eaa..8066235679 100644 --- a/spring-cloud-modules/spring-cloud-netflix-sidecar/echo-demo/pom.xml +++ b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-echo-demo/pom.xml @@ -2,8 +2,8 @@ 4.0.0 - echo-demo - echo-demo + spring-cloud-netflix-sidecar-echo-demo + spring-cloud-netflix-sidecar-echo-demo Demo for echo endpoint com.baeldung.cloud diff --git a/spring-cloud-modules/spring-cloud-netflix-sidecar/echo-demo/src/main/java/com/baeldung/cloud/echo/EchoApplication.java b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-echo-demo/src/main/java/com/baeldung/cloud/echo/EchoApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-netflix-sidecar/echo-demo/src/main/java/com/baeldung/cloud/echo/EchoApplication.java rename to spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-echo-demo/src/main/java/com/baeldung/cloud/echo/EchoApplication.java diff --git a/spring-cloud-modules/spring-cloud-netflix-sidecar/echo-demo/src/main/resources/application.yml b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-echo-demo/src/main/resources/application.yml similarity index 100% rename from spring-cloud-modules/spring-cloud-netflix-sidecar/echo-demo/src/main/resources/application.yml rename to spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-echo-demo/src/main/resources/application.yml diff --git a/spring-cloud-modules/spring-cloud-netflix-sidecar/echo-demo/src/test/java/com/baeldung/cloud/echo/SpringContextTest.java b/spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-echo-demo/src/test/java/com/baeldung/cloud/echo/SpringContextTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-netflix-sidecar/echo-demo/src/test/java/com/baeldung/cloud/echo/SpringContextTest.java rename to spring-cloud-modules/spring-cloud-netflix-sidecar/spring-cloud-netflix-sidecar-echo-demo/src/test/java/com/baeldung/cloud/echo/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-zookeeper/pom.xml b/spring-cloud-modules/spring-cloud-zookeeper/pom.xml index a3567adb06..7ada9f0cc9 100644 --- a/spring-cloud-modules/spring-cloud-zookeeper/pom.xml +++ b/spring-cloud-modules/spring-cloud-zookeeper/pom.xml @@ -14,8 +14,8 @@ - Greeting - HelloWorld + spring-cloud-zookeeper-greeting + spring-cloud-zookeeper-helloworld \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-zookeeper/Greeting/pom.xml b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/pom.xml similarity index 96% rename from spring-cloud-modules/spring-cloud-zookeeper/Greeting/pom.xml rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/pom.xml index 8248884632..b6f711f72d 100644 --- a/spring-cloud-modules/spring-cloud-zookeeper/Greeting/pom.xml +++ b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/pom.xml @@ -3,8 +3,8 @@ 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"> 4.0.0 - Greeting - Greeting + spring-cloud-zookeeper-greeting + spring-cloud-zookeeper-greeting jar diff --git a/spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/java/com/baeldung/spring/cloud/greeting/GreetingApplication.java b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/java/com/baeldung/spring/cloud/greeting/GreetingApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/java/com/baeldung/spring/cloud/greeting/GreetingApplication.java rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/java/com/baeldung/spring/cloud/greeting/GreetingApplication.java diff --git a/spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/java/com/baeldung/spring/cloud/greeting/GreetingController.java b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/java/com/baeldung/spring/cloud/greeting/GreetingController.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/java/com/baeldung/spring/cloud/greeting/GreetingController.java rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/java/com/baeldung/spring/cloud/greeting/GreetingController.java diff --git a/spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/java/com/baeldung/spring/cloud/greeting/HelloWorldClient.java b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/java/com/baeldung/spring/cloud/greeting/HelloWorldClient.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/java/com/baeldung/spring/cloud/greeting/HelloWorldClient.java rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/java/com/baeldung/spring/cloud/greeting/HelloWorldClient.java diff --git a/spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/resources/application.yml b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/resources/application.yml similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/resources/application.yml rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/resources/application.yml diff --git a/spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/resources/logback.xml b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/resources/logback.xml similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/resources/logback.xml rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/resources/logback.xml diff --git a/spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/resources/templates/greeting-view.html b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/resources/templates/greeting-view.html similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/main/resources/templates/greeting-view.html rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/main/resources/templates/greeting-view.html diff --git a/spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/test/java/com/baeldung/SpringContextTest.java b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/Greeting/src/test/java/com/baeldung/SpringContextTest.java rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-greeting/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/pom.xml b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/pom.xml similarity index 95% rename from spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/pom.xml rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/pom.xml index 57a1cc029c..e9baf2b174 100644 --- a/spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/pom.xml +++ b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/pom.xml @@ -3,8 +3,8 @@ 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"> 4.0.0 - HelloWorld - HelloWorld + spring-cloud-zookeeper-helloworld + spring-cloud-zookeeper-helloworld jar diff --git a/spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/src/main/java/com/baeldung/spring/cloud/helloworld/HelloWorldApplication.java b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/src/main/java/com/baeldung/spring/cloud/helloworld/HelloWorldApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/src/main/java/com/baeldung/spring/cloud/helloworld/HelloWorldApplication.java rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/src/main/java/com/baeldung/spring/cloud/helloworld/HelloWorldApplication.java diff --git a/spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/src/main/java/com/baeldung/spring/cloud/helloworld/HelloWorldController.java b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/src/main/java/com/baeldung/spring/cloud/helloworld/HelloWorldController.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/src/main/java/com/baeldung/spring/cloud/helloworld/HelloWorldController.java rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/src/main/java/com/baeldung/spring/cloud/helloworld/HelloWorldController.java diff --git a/spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/src/main/resources/application.yml b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/src/main/resources/application.yml similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/src/main/resources/application.yml rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/src/main/resources/application.yml diff --git a/spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/src/main/resources/logback.xml b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/src/main/resources/logback.xml similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/src/main/resources/logback.xml rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/src/main/resources/logback.xml diff --git a/spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/src/test/java/com/baeldung/spring/cloud/helloworld/SpringContextTest.java b/spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/src/test/java/com/baeldung/spring/cloud/helloworld/SpringContextTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zookeeper/HelloWorld/src/test/java/com/baeldung/spring/cloud/helloworld/SpringContextTest.java rename to spring-cloud-modules/spring-cloud-zookeeper/spring-cloud-zookeeper-helloworld/src/test/java/com/baeldung/spring/cloud/helloworld/SpringContextTest.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/pom.xml b/spring-cloud-modules/spring-cloud-zuul-fallback/pom.xml index 7cddec48fe..0cd13735f2 100644 --- a/spring-cloud-modules/spring-cloud-zuul-fallback/pom.xml +++ b/spring-cloud-modules/spring-cloud-zuul-fallback/pom.xml @@ -15,8 +15,8 @@ - api-gateway - weather-service + spring-cloud-zuul-fallback-api-gateway + spring-cloud-zuul-fallback-weather-service diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/pom.xml b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/pom.xml similarity index 93% rename from spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/pom.xml rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/pom.xml index 13bfabeb3b..bdc3d0c2bc 100644 --- a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/pom.xml +++ b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/pom.xml @@ -3,8 +3,8 @@ 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"> 4.0.0 - api-gateway - api-gateway + spring-cloud-zuul-fallback-api-gateway + spring-cloud-zuul-fallback-api-gateway jar API Gateway using Zuul diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/ApiGatewayApplication.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/ApiGatewayApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/ApiGatewayApplication.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/ApiGatewayApplication.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayClientResponse.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayClientResponse.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayClientResponse.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayClientResponse.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayServiceFallback.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayServiceFallback.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayServiceFallback.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayServiceFallback.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/WeatherServiceFallback.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/WeatherServiceFallback.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/WeatherServiceFallback.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/main/java/com/baeldung/spring/cloud/apigateway/fallback/WeatherServiceFallback.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/main/resources/application.yml b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/main/resources/application.yml similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/main/resources/application.yml rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/main/resources/application.yml diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/ApiGatewayApplicationIntegrationTest.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/ApiGatewayApplicationIntegrationTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/ApiGatewayApplicationIntegrationTest.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/ApiGatewayApplicationIntegrationTest.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayServiceFallbackUnitTest.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayServiceFallbackUnitTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayServiceFallbackUnitTest.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/fallback/GatewayServiceFallbackUnitTest.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/fallback/WeatherServiceFallbackUnitTest.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/fallback/WeatherServiceFallbackUnitTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/fallback/WeatherServiceFallbackUnitTest.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/test/java/com/baeldung/spring/cloud/apigateway/fallback/WeatherServiceFallbackUnitTest.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/test/resources/logback.xml b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/test/resources/logback.xml similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/api-gateway/src/test/resources/logback.xml rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-api-gateway/src/test/resources/logback.xml diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/pom.xml b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/pom.xml similarity index 92% rename from spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/pom.xml rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/pom.xml index 239be5e134..743684bcd3 100644 --- a/spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/pom.xml +++ b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/pom.xml @@ -3,8 +3,8 @@ 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"> 4.0.0 - weather-service - weather-service + spring-cloud-zuul-fallback-weather-service + spring-cloud-zuul-fallback-weather-service Weather Service for Zuul Fallback Test diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/src/main/java/com/baeldung/spring/cloud/weatherservice/WeatherController.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/src/main/java/com/baeldung/spring/cloud/weatherservice/WeatherController.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/src/main/java/com/baeldung/spring/cloud/weatherservice/WeatherController.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/src/main/java/com/baeldung/spring/cloud/weatherservice/WeatherController.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/src/main/java/com/baeldung/spring/cloud/weatherservice/WeatherServiceApplication.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/src/main/java/com/baeldung/spring/cloud/weatherservice/WeatherServiceApplication.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/src/main/java/com/baeldung/spring/cloud/weatherservice/WeatherServiceApplication.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/src/main/java/com/baeldung/spring/cloud/weatherservice/WeatherServiceApplication.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/src/main/resources/application.yml b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/src/main/resources/application.yml similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/src/main/resources/application.yml rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/src/main/resources/application.yml diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/src/test/java/com/baeldung/spring/cloud/weatherservice/WeatherControllerIntegrationTest.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/src/test/java/com/baeldung/spring/cloud/weatherservice/WeatherControllerIntegrationTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/src/test/java/com/baeldung/spring/cloud/weatherservice/WeatherControllerIntegrationTest.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/src/test/java/com/baeldung/spring/cloud/weatherservice/WeatherControllerIntegrationTest.java diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/src/test/java/com/baeldung/spring/cloud/weatherservice/WeatherServiceApplicationIntegrationTest.java b/spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/src/test/java/com/baeldung/spring/cloud/weatherservice/WeatherServiceApplicationIntegrationTest.java similarity index 100% rename from spring-cloud-modules/spring-cloud-zuul-fallback/weather-service/src/test/java/com/baeldung/spring/cloud/weatherservice/WeatherServiceApplicationIntegrationTest.java rename to spring-cloud-modules/spring-cloud-zuul-fallback/spring-cloud-zuul-fallback-weather-service/src/test/java/com/baeldung/spring/cloud/weatherservice/WeatherServiceApplicationIntegrationTest.java diff --git a/spring-security-modules/spring-security-web-angular/pom.xml b/spring-security-modules/spring-security-web-angular/pom.xml index cf23501dff..15dc4d007c 100644 --- a/spring-security-modules/spring-security-web-angular/pom.xml +++ b/spring-security-modules/spring-security-web-angular/pom.xml @@ -15,7 +15,7 @@ - server + spring-security-web-angular-server \ No newline at end of file diff --git a/spring-security-modules/spring-security-web-angular/client/anguarjs/app.js b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/app.js similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/anguarjs/app.js rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/app.js diff --git a/spring-security-modules/spring-security-web-angular/client/anguarjs/home/home.controller.js b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/home/home.controller.js similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/anguarjs/home/home.controller.js rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/home/home.controller.js diff --git a/spring-security-modules/spring-security-web-angular/client/anguarjs/home/home.view.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/home/home.view.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/anguarjs/home/home.view.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/home/home.view.html diff --git a/spring-security-modules/spring-security-web-angular/client/anguarjs/index.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/index.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/anguarjs/index.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/index.html diff --git a/spring-security-modules/spring-security-web-angular/client/anguarjs/login/login.controller.js b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/login/login.controller.js similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/anguarjs/login/login.controller.js rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/login/login.controller.js diff --git a/spring-security-modules/spring-security-web-angular/client/anguarjs/login/login.view.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/login/login.view.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/anguarjs/login/login.view.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/anguarjs/login/login.view.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/app.css b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app.css similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/app.css rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app.css diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/app/app.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/app.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/app/app.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/app.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/app/app.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/app.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/app/app.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/app.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/app/app.module.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/app.module.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/app/app.module.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/app.module.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/app/app.routing.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/app.routing.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/app/app.routing.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/app.routing.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/app/home/home.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/home/home.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/app/home/home.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/home/home.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/app/home/home.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/home/home.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/app/home/home.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/home/home.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/app/login/login.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/login/login.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/app/login/login.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/login/login.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/app/login/login.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/login/login.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/app/login/login.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/login/login.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/app/main.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/main.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/app/main.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/app/main.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/index.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/index.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/index.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/index.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/package.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/package.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/package.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/package.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/systemjs.config.js b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/systemjs.config.js similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/systemjs.config.js rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/systemjs.config.js diff --git a/spring-security-modules/spring-security-web-angular/client/angular2/tsconfig.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/tsconfig.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular2/tsconfig.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular2/tsconfig.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/.angular-cli.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/.angular-cli.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/.angular-cli.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/.angular-cli.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/package.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/package.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/package.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/package.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/app/app.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/app.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/app/app.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/app.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/app/app.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/app.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/app/app.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/app.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/app/app.module.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/app.module.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/app/app.module.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/app.module.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/app/app.routing.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/app.routing.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/app/app.routing.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/app.routing.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/app/home/home.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/home/home.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/app/home/home.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/home/home.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/app/home/home.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/home/home.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/app/home/home.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/home/home.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/app/login/login.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/login/login.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/app/login/login.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/login/login.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/app/login/login.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/login/login.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/app/login/login.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/app/login/login.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/index.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/index.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/index.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/index.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/main.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/main.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/main.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/main.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/polyfills.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/polyfills.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/polyfills.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/polyfills.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/styles.css b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/styles.css similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/styles.css rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/styles.css diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/src/tsconfig.app.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/tsconfig.app.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/src/tsconfig.app.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/src/tsconfig.app.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/tsconfig.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/tsconfig.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/tsconfig.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/tsconfig.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular4/tslint.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/tslint.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular4/tslint.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular4/tslint.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/.angular-cli.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/.angular-cli.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/.angular-cli.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/.angular-cli.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/package.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/package.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/package.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/package.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/app/app.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/app.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/app/app.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/app.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/app/app.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/app.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/app/app.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/app.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/app/app.module.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/app.module.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/app/app.module.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/app.module.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/app/app.routing.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/app.routing.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/app/app.routing.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/app.routing.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/app/home/home.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/home/home.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/app/home/home.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/home/home.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/app/home/home.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/home/home.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/app/home/home.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/home/home.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/app/login/login.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/login/login.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/app/login/login.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/login/login.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/app/login/login.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/login/login.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/app/login/login.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/app/login/login.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/index.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/index.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/index.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/index.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/main.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/main.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/main.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/main.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/polyfills.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/polyfills.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/polyfills.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/polyfills.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/styles.css b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/styles.css similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/styles.css rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/styles.css diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/src/tsconfig.app.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/tsconfig.app.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/src/tsconfig.app.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/src/tsconfig.app.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/tsconfig.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/tsconfig.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/tsconfig.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/tsconfig.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular5/tslint.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/tslint.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular5/tslint.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular5/tslint.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/angular.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/angular.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/angular.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/angular.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/package.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/package.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/package.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/package.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/app/app.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/app.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/app/app.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/app.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/app/app.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/app.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/app/app.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/app.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/app/app.module.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/app.module.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/app/app.module.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/app.module.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/app/app.routing.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/app.routing.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/app/app.routing.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/app.routing.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/app/home/home.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/home/home.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/app/home/home.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/home/home.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/app/home/home.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/home/home.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/app/home/home.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/home/home.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/app/login/login.component.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/login/login.component.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/app/login/login.component.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/login/login.component.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/app/login/login.component.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/login/login.component.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/app/login/login.component.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/app/login/login.component.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/index.html b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/index.html similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/index.html rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/index.html diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/main.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/main.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/main.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/main.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/polyfills.ts b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/polyfills.ts similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/polyfills.ts rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/polyfills.ts diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/styles.css b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/styles.css similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/styles.css rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/styles.css diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/src/tsconfig.app.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/tsconfig.app.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/src/tsconfig.app.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/src/tsconfig.app.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/tsconfig.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/tsconfig.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/tsconfig.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/tsconfig.json diff --git a/spring-security-modules/spring-security-web-angular/client/angular6/tslint.json b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/tslint.json similarity index 100% rename from spring-security-modules/spring-security-web-angular/client/angular6/tslint.json rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-client/angular6/tslint.json diff --git a/spring-security-modules/spring-security-web-angular/server/pom.xml b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/pom.xml similarity index 95% rename from spring-security-modules/spring-security-web-angular/server/pom.xml rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/pom.xml index a1f4a9f998..c188541bbb 100644 --- a/spring-security-modules/spring-security-web-angular/server/pom.xml +++ b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/pom.xml @@ -3,8 +3,8 @@ 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"> 4.0.0 - server - server + spring-security-web-angular-server + spring-security-web-angular-server jar Spring Security Angular diff --git a/spring-security-modules/spring-security-web-angular/server/src/main/java/com/baeldung/springbootsecurityrest/basicauth/SpringBootSecurityApplication.java b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/java/com/baeldung/springbootsecurityrest/basicauth/SpringBootSecurityApplication.java similarity index 100% rename from spring-security-modules/spring-security-web-angular/server/src/main/java/com/baeldung/springbootsecurityrest/basicauth/SpringBootSecurityApplication.java rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/java/com/baeldung/springbootsecurityrest/basicauth/SpringBootSecurityApplication.java diff --git a/spring-security-modules/spring-security-web-angular/server/src/main/java/com/baeldung/springbootsecurityrest/basicauth/config/BasicAuthConfiguration.java b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/java/com/baeldung/springbootsecurityrest/basicauth/config/BasicAuthConfiguration.java similarity index 100% rename from spring-security-modules/spring-security-web-angular/server/src/main/java/com/baeldung/springbootsecurityrest/basicauth/config/BasicAuthConfiguration.java rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/java/com/baeldung/springbootsecurityrest/basicauth/config/BasicAuthConfiguration.java diff --git a/spring-security-modules/spring-security-web-angular/server/src/main/java/com/baeldung/springbootsecurityrest/controller/UserController.java b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/java/com/baeldung/springbootsecurityrest/controller/UserController.java similarity index 100% rename from spring-security-modules/spring-security-web-angular/server/src/main/java/com/baeldung/springbootsecurityrest/controller/UserController.java rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/java/com/baeldung/springbootsecurityrest/controller/UserController.java diff --git a/spring-security-modules/spring-security-web-angular/server/src/main/java/com/baeldung/springbootsecurityrest/vo/User.java b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/java/com/baeldung/springbootsecurityrest/vo/User.java similarity index 100% rename from spring-security-modules/spring-security-web-angular/server/src/main/java/com/baeldung/springbootsecurityrest/vo/User.java rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/java/com/baeldung/springbootsecurityrest/vo/User.java diff --git a/spring-security-modules/spring-security-web-angular/server/src/main/resources/application.properties b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/resources/application.properties similarity index 100% rename from spring-security-modules/spring-security-web-angular/server/src/main/resources/application.properties rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/resources/application.properties diff --git a/spring-security-modules/spring-security-web-angular/server/src/main/resources/logback.xml b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/resources/logback.xml similarity index 100% rename from spring-security-modules/spring-security-web-angular/server/src/main/resources/logback.xml rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/main/resources/logback.xml diff --git a/spring-security-modules/spring-security-web-angular/server/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-security-modules/spring-security-web-angular/server/src/test/java/com/baeldung/SpringContextTest.java rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-security-modules/spring-security-web-angular/server/src/test/java/com/baeldung/springbootsecurityrest/BasicAuthConfigurationIntegrationTest.java b/spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/test/java/com/baeldung/springbootsecurityrest/BasicAuthConfigurationIntegrationTest.java similarity index 100% rename from spring-security-modules/spring-security-web-angular/server/src/test/java/com/baeldung/springbootsecurityrest/BasicAuthConfigurationIntegrationTest.java rename to spring-security-modules/spring-security-web-angular/spring-security-web-angular-server/src/test/java/com/baeldung/springbootsecurityrest/BasicAuthConfigurationIntegrationTest.java diff --git a/struts/README.md b/struts/README.md new file mode 100644 index 0000000000..d15b94f662 --- /dev/null +++ b/struts/README.md @@ -0,0 +1,7 @@ +## Struts 2 + +This module contains articles about Struts 2 + +### Relevant articles + +- [A Quick Struts 2 Intro](https://www.baeldung.com/struts-2-intro) diff --git a/struts/WebContent/WEB-INF/web.xml b/struts/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..8f1b55943c --- /dev/null +++ b/struts/WebContent/WEB-INF/web.xml @@ -0,0 +1,12 @@ + + + struts + + struts2 + org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter + + + struts2 + /* + + \ No newline at end of file diff --git a/struts/WebContent/input.jsp b/struts/WebContent/input.jsp new file mode 100644 index 0000000000..6d80aa3ffd --- /dev/null +++ b/struts/WebContent/input.jsp @@ -0,0 +1,21 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Baledung Struts + + +
+

Welcome to Baeldung Struts 2 app

+

Which car do you like !!

+

Please choose ferrari or bmw

+ + +
+ + \ No newline at end of file diff --git a/struts/WebContent/result.jsp b/struts/WebContent/result.jsp new file mode 100644 index 0000000000..0fe9ea2d1d --- /dev/null +++ b/struts/WebContent/result.jsp @@ -0,0 +1,11 @@ +<%@ page contentType="text/html; charset=UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> + + +Hello World + + +

Hello Baeldung User

+

You are a

+ + diff --git a/struts/pom.xml b/struts/pom.xml new file mode 100644 index 0000000000..a668ea29db --- /dev/null +++ b/struts/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + struts + 0.0.1-SNAPSHOT + struts + pom + + + com.baeldung + parent-spring-4 + 0.0.1-SNAPSHOT + ../parent-spring-4 + + + + + org.apache.struts + struts2-core + ${struts2.version} + + + org.apache.struts + struts2-junit-plugin + ${struts2.version} + + + org.apache.struts + struts2-convention-plugin + ${struts2-convention-plugin.version} + + + javax.servlet + javax.servlet-api + ${javax.servlet-api.version} + + + org.springframework + spring-core + ${spring.version} + + + commons-logging + commons-logging + + + + + + + src/main/java + + + src/main/resources + + + + + maven-war-plugin + ${maven-war-plugin.version} + + WebContent + + + + + + + 2.5.5 + 2.5.8 + 4.3.6.RELEASE + + + \ No newline at end of file diff --git a/struts/src/main/java/com/baeldung/struts/CarAction.java b/struts/src/main/java/com/baeldung/struts/CarAction.java new file mode 100644 index 0000000000..478f3b4cc2 --- /dev/null +++ b/struts/src/main/java/com/baeldung/struts/CarAction.java @@ -0,0 +1,37 @@ +package com.baeldung.struts; + +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.Result; + +@Namespace("/tutorial") +@Action("/car") +@Result(name = "success", location = "/result.jsp") +public class CarAction { + private String carName; + private String carMessage; + private CarMessageService carMessageService = new CarMessageService(); + + public String execute() { + System.out.println("inside execute(): carName is" + carName); + this.setCarMessage(this.carMessageService.getMessage(carName)); + return "success"; + } + + public String getCarName() { + return carName; + } + + public void setCarName(String carName) { + this.carName = carName; + } + + public String getCarMessage() { + return carMessage; + } + + public void setCarMessage(String carMessage) { + this.carMessage = carMessage; + } + +} diff --git a/struts/src/main/java/com/baeldung/struts/CarMessageService.java b/struts/src/main/java/com/baeldung/struts/CarMessageService.java new file mode 100644 index 0000000000..34d3ca3d76 --- /dev/null +++ b/struts/src/main/java/com/baeldung/struts/CarMessageService.java @@ -0,0 +1,18 @@ +package com.baeldung.struts; + +public class CarMessageService { + + public String getMessage(String carName) { + System.out.println("inside getMessage()" + carName); + if (carName.equalsIgnoreCase("ferrari")){ + return "Ferrari Fan!"; + } + else if (carName.equalsIgnoreCase("bmw")){ + return "BMW Fan!"; + } + else{ + return "please choose ferrari Or bmw"; + } + } + +} diff --git a/struts/src/main/resources/logback.xml b/struts/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/struts/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/struts/src/test/java/com/baeldung/struts/test/CarActionTest.java b/struts/src/test/java/com/baeldung/struts/test/CarActionTest.java new file mode 100644 index 0000000000..64b640edfb --- /dev/null +++ b/struts/src/test/java/com/baeldung/struts/test/CarActionTest.java @@ -0,0 +1,29 @@ +//package com.baeldung.struts.test; +// +//import org.apache.struts2.StrutsTestCase; +//import org.junit.Test; +// +//import com.baeldung.struts.CarAction; +//import com.opensymphony.xwork2.ActionProxy; +// +//public class CarActionTest extends StrutsTestCase { +// +// public void testgivenCarOptions_WhenferrariSelected_ThenShowMessage() throws Exception { +// request.setParameter("carName", "ferrari"); +// ActionProxy proxy = getActionProxy("/tutorial/car.action"); +// CarAction carAction = (CarAction) proxy.getAction(); +// String result = proxy.execute(); +// assertEquals(result, "success"); +// assertEquals(carAction.getCarMessage(), "Ferrari Fan!"); +// } +// +// public void testgivenCarOptions_WhenbmwSelected_ThenShowMessage() throws Exception { +// request.setParameter("carName", "bmw"); +// ActionProxy proxy = getActionProxy("/tutorial/car.action"); +// CarAction carAction = (CarAction) proxy.getAction(); +// String result = proxy.execute(); +// assertEquals(result, "success"); +// assertEquals(carAction.getCarMessage(), "BMW Fan!"); +// } +// +//} From 0ea458117e3cb92399f78f264ddabbefef06d11d Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Sat, 27 Aug 2022 03:26:38 +0200 Subject: [PATCH 26/35] List all factors of a number in Java (#12646) * List all factors of a number in Java * format the map code in the test --- .../baeldung/factors/FactorsOfInteger.java | 39 ++++++++++++++++++ .../factors/FactorsOfIntegerUnitTest.java | 40 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 core-java-modules/core-java-numbers-5/src/main/java/com/baeldung/factors/FactorsOfInteger.java create mode 100644 core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/factors/FactorsOfIntegerUnitTest.java diff --git a/core-java-modules/core-java-numbers-5/src/main/java/com/baeldung/factors/FactorsOfInteger.java b/core-java-modules/core-java-numbers-5/src/main/java/com/baeldung/factors/FactorsOfInteger.java new file mode 100644 index 0000000000..a623a7b81e --- /dev/null +++ b/core-java-modules/core-java-numbers-5/src/main/java/com/baeldung/factors/FactorsOfInteger.java @@ -0,0 +1,39 @@ +package com.baeldung.factors; + +import java.util.HashSet; +import java.util.Set; + +public class FactorsOfInteger { + public static Set getAllFactorsVer1(int n) { + Set factors = new HashSet<>(); + for (int i = 1; i <= n; i++) { + if (n % i == 0) { + factors.add(i); + } + } + return factors; + } + + public static Set getAllFactorsVer2(int n) { + Set factors = new HashSet<>(); + for (int i = 1; i <= Math.sqrt(n); i++) { + if (n % i == 0) { + factors.add(i); + factors.add(n / i); + } + } + return factors; + } + + public static Set getAllFactorsVer3(int n) { + Set factors = new HashSet<>(); + int step = n % 2 == 0 ? 1 : 2; + for (int i = 1; i <= Math.sqrt(n); i += step) { + if (n % i == 0) { + factors.add(i); + factors.add(n / i); + } + } + return factors; + } +} diff --git a/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/factors/FactorsOfIntegerUnitTest.java b/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/factors/FactorsOfIntegerUnitTest.java new file mode 100644 index 0000000000..8a4105ed5a --- /dev/null +++ b/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/factors/FactorsOfIntegerUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.factors; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Map; +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +class FactorsOfIntegerUnitTest { + //@formatter:off + private final static Map> FACTOR_MAP = ImmutableMap.of( + 0, ImmutableSet.of(), + 1, ImmutableSet.of(1), + 20, ImmutableSet.of(1, 2, 4, 5, 10, 20), + 24, ImmutableSet.of(1, 2, 3, 4, 6, 8, 12, 24), + 97, ImmutableSet.of(1, 97), + 99, ImmutableSet.of(1, 3, 9, 11, 33, 99), + 100, ImmutableSet.of(1, 2, 4, 5, 10, 20, 25, 50, 100) + ); + //@formatter:on + + @Test + void givenAnInteger_whenCallingFindAllFactorsTheDraftVersion_shouldGetExpectedResult() { + FACTOR_MAP.forEach((number, expected) -> assertEquals(expected, FactorsOfInteger.getAllFactorsVer1(number))); + } + + @Test + void givenAnInteger_whenCallingFindAllFactorsVer2_shouldGetExpectedResult() { + FACTOR_MAP.forEach((number, expected) -> assertEquals(expected, FactorsOfInteger.getAllFactorsVer2(number))); + } + + @Test + void givenAnInteger_whenCallingFindAllFactorsVer3_shouldGetExpectedResult() { + FACTOR_MAP.forEach((number, expected) -> assertEquals(expected, FactorsOfInteger.getAllFactorsVer3(number))); + } +} From d8599a4c3582c4a952a969f6cb3bf1c7afa49692 Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Sat, 27 Aug 2022 18:07:36 +0200 Subject: [PATCH 27/35] Remove the last character of a Java StringBuilder (#12653) --- .../RemoveLastCharFromSbUnitTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 core-java-modules/core-java-string-apis/src/test/java/com/baeldung/removelastcharfromsb/RemoveLastCharFromSbUnitTest.java diff --git a/core-java-modules/core-java-string-apis/src/test/java/com/baeldung/removelastcharfromsb/RemoveLastCharFromSbUnitTest.java b/core-java-modules/core-java-string-apis/src/test/java/com/baeldung/removelastcharfromsb/RemoveLastCharFromSbUnitTest.java new file mode 100644 index 0000000000..8c1a4306ea --- /dev/null +++ b/core-java-modules/core-java-string-apis/src/test/java/com/baeldung/removelastcharfromsb/RemoveLastCharFromSbUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.removelastcharfromsb; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +class RemoveLastCharFromSbUnitTest { + @Test + void givenSb_whenRemovingUsingDeleteCharAt_shouldGetExpectedResult() { + StringBuilder sb = new StringBuilder("Using the sb.deleteCharAt() method!"); + sb.deleteCharAt(sb.length() - 1); + assertEquals("Using the sb.deleteCharAt() method", sb.toString()); + } + + @Test + void givenSb_whenRemovingUsingReplace_shouldGetExpectedResult() { + StringBuilder sb = new StringBuilder("Using the sb.replace() method!"); + int last = sb.length() - 1; + sb.replace(last, last + 1, ""); + assertEquals("Using the sb.replace() method", sb.toString()); + } + + @Test + void givenSb_whenRemovingUsingSubString_shouldGetExpectedResult() { + StringBuilder sb = new StringBuilder("Using the sb.substring() method!"); + assertEquals("Using the sb.substring() method", sb.substring(0, sb.length() - 1)); + //the stringBuilder object is not changed + assertEquals("Using the sb.substring() method!", sb.toString()); + } +} From a979ac2f4747e7521d38cc489d2653f2038277a5 Mon Sep 17 00:00:00 2001 From: "thibault.faure" Date: Sat, 27 Aug 2022 20:40:10 +0200 Subject: [PATCH 28/35] BAEL-5511 code for the Rebuild docker container with docker-compose article --- .../rebuild-container/docker-compose-independents.yml | 8 ++++++++ .../docker-compose-with-dependency.yml | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 docker-modules/docker-compose/rebuild-container/docker-compose-independents.yml create mode 100644 docker-modules/docker-compose/rebuild-container/docker-compose-with-dependency.yml diff --git a/docker-modules/docker-compose/rebuild-container/docker-compose-independents.yml b/docker-modules/docker-compose/rebuild-container/docker-compose-independents.yml new file mode 100644 index 0000000000..edf0934bc9 --- /dev/null +++ b/docker-modules/docker-compose/rebuild-container/docker-compose-independents.yml @@ -0,0 +1,8 @@ +version: "3.9" +services: + ubuntu: + image: "ubuntu:latest" + tty: true + alpine: + image: "alpine:latest" + tty: true \ No newline at end of file diff --git a/docker-modules/docker-compose/rebuild-container/docker-compose-with-dependency.yml b/docker-modules/docker-compose/rebuild-container/docker-compose-with-dependency.yml new file mode 100644 index 0000000000..49852dbd78 --- /dev/null +++ b/docker-modules/docker-compose/rebuild-container/docker-compose-with-dependency.yml @@ -0,0 +1,10 @@ +version: "3.9" +services: + ubuntu: + image: "ubuntu:latest" + tty: true + depends_on: + - "alpine" + alpine: + image: "alpine:latest" + tty: true \ No newline at end of file From 0bbab5326c3cde223da0bbf404dffd59cb8efd29 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Sun, 28 Aug 2022 14:03:11 +0100 Subject: [PATCH 29/35] [JAVA-13976] Fix integration tests after Spring Boot upgrade to 2.7.2 (#12656) --- .../src/main/resources/application.properties | 2 ++ vavr-modules/vavr/src/main/resources/application.properties | 1 + 2 files changed, 3 insertions(+) create mode 100644 vavr-modules/vavr/src/main/resources/application.properties diff --git a/spring-web-modules/spring-mvc-basics-3/src/main/resources/application.properties b/spring-web-modules/spring-mvc-basics-3/src/main/resources/application.properties index fcdaabe007..708ec5d3dd 100644 --- a/spring-web-modules/spring-mvc-basics-3/src/main/resources/application.properties +++ b/spring-web-modules/spring-mvc-basics-3/src/main/resources/application.properties @@ -5,3 +5,5 @@ spring.thymeleaf.cache=false spring.thymeleaf.enabled=true spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix=.html + +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/vavr-modules/vavr/src/main/resources/application.properties b/vavr-modules/vavr/src/main/resources/application.properties new file mode 100644 index 0000000000..ead0df89a3 --- /dev/null +++ b/vavr-modules/vavr/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.jpa.properties.hibernate.globally_quoted_identifiers=true From 1ce3754d163b23cf10da1c569fce6e6759a18562 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Sun, 28 Aug 2022 18:36:58 +0530 Subject: [PATCH 30/35] JAVA-13947 Potential issue in A Solid Guide to SOLID Principles article (#12654) --- patterns/solid/src/main/java/com/baeldung/s/BadBook.java | 4 ++-- patterns/solid/src/main/java/com/baeldung/s/GoodBook.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/patterns/solid/src/main/java/com/baeldung/s/BadBook.java b/patterns/solid/src/main/java/com/baeldung/s/BadBook.java index 03c8fcd488..2712314db1 100644 --- a/patterns/solid/src/main/java/com/baeldung/s/BadBook.java +++ b/patterns/solid/src/main/java/com/baeldung/s/BadBook.java @@ -10,8 +10,8 @@ public class BadBook { //methods that directly relate to the book properties - public String replaceWordInText(String word){ - return text.replaceAll(word, text); + public String replaceWordInText(String word, String replacementWord){ + return text.replaceAll(word, replacementWord); } public boolean isWordInText(String word){ diff --git a/patterns/solid/src/main/java/com/baeldung/s/GoodBook.java b/patterns/solid/src/main/java/com/baeldung/s/GoodBook.java index b0993aca2b..04606bcdcd 100644 --- a/patterns/solid/src/main/java/com/baeldung/s/GoodBook.java +++ b/patterns/solid/src/main/java/com/baeldung/s/GoodBook.java @@ -9,8 +9,8 @@ public class GoodBook { //constructor, getters and setters //methods that directly relate to the book properties - public String replaceWordInText(String word){ - return text.replaceAll(word, text); + public String replaceWordInText(String word, String replacementWord){ + return text.replaceAll(word, replacementWord); } public boolean isWordInText(String word){ From 46511387b08f4b8f5acc3e83927359b95028ef89 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Sun, 28 Aug 2022 18:41:49 +0530 Subject: [PATCH 31/35] JAVA-13865 POM Properties Cleanup - Week 28 - 2022 (#12645) * JAVA-13865 POM Properties Cleanup - Week 28 - 2022 * JAVA-13865 Remove unnecessary white spaces --- akka-modules/akka-http/pom.xml | 8 ++++---- akka-modules/akka-streams/pom.xml | 1 - akka-modules/pom.xml | 4 ++++ akka-modules/spring-akka/pom.xml | 1 - algorithms-modules/algorithms-genetic/pom.xml | 2 -- algorithms-modules/algorithms-miscellaneous-1/pom.xml | 3 --- algorithms-modules/algorithms-miscellaneous-2/pom.xml | 4 ---- algorithms-modules/algorithms-miscellaneous-5/pom.xml | 6 ------ algorithms-modules/algorithms-miscellaneous-6/pom.xml | 4 ---- algorithms-modules/algorithms-sorting-2/pom.xml | 5 ----- algorithms-modules/algorithms-sorting/pom.xml | 5 ----- algorithms-modules/pom.xml | 7 +++++++ aws-modules/aws-lambda/lambda/pom.xml | 2 -- aws-modules/aws-miscellaneous/pom.xml | 2 -- aws-modules/aws-s3/pom.xml | 2 -- aws-modules/pom.xml | 4 ++++ 16 files changed, 19 insertions(+), 41 deletions(-) diff --git a/akka-modules/akka-http/pom.xml b/akka-modules/akka-http/pom.xml index cf7e0b95ab..9372107fc9 100644 --- a/akka-modules/akka-http/pom.xml +++ b/akka-modules/akka-http/pom.xml @@ -15,22 +15,22 @@ com.typesafe.akka - akka-http_2.12 + akka-http_${scala.version} ${akka.http.version} com.typesafe.akka - akka-stream_2.12 + akka-stream_${scala.version} ${akka.stream.version} com.typesafe.akka - akka-http-jackson_2.12 + akka-http-jackson_${scala.version} ${akka.http.version} com.typesafe.akka - akka-http-testkit_2.12 + akka-http-testkit_${scala.version} ${akka.http.version} test diff --git a/akka-modules/akka-streams/pom.xml b/akka-modules/akka-streams/pom.xml index b563d07400..adf6e9b3d9 100644 --- a/akka-modules/akka-streams/pom.xml +++ b/akka-modules/akka-streams/pom.xml @@ -27,7 +27,6 @@ 2.5.2 - 2.11 \ No newline at end of file diff --git a/akka-modules/pom.xml b/akka-modules/pom.xml index 0e3563f31a..3a9d5e41ff 100644 --- a/akka-modules/pom.xml +++ b/akka-modules/pom.xml @@ -30,4 +30,8 @@
+ + 2.12 + + \ No newline at end of file diff --git a/akka-modules/spring-akka/pom.xml b/akka-modules/spring-akka/pom.xml index c43d850462..7451a40b86 100644 --- a/akka-modules/spring-akka/pom.xml +++ b/akka-modules/spring-akka/pom.xml @@ -45,7 +45,6 @@ 4.3.4.RELEASE 2.4.14 - 2.11 \ No newline at end of file diff --git a/algorithms-modules/algorithms-genetic/pom.xml b/algorithms-modules/algorithms-genetic/pom.xml index c18ba0e7f1..ff6afde191 100644 --- a/algorithms-modules/algorithms-genetic/pom.xml +++ b/algorithms-modules/algorithms-genetic/pom.xml @@ -38,9 +38,7 @@ - 3.6.1 3.7.0 - 1.11 \ No newline at end of file diff --git a/algorithms-modules/algorithms-miscellaneous-1/pom.xml b/algorithms-modules/algorithms-miscellaneous-1/pom.xml index 62c9738f1a..a1ac607c29 100644 --- a/algorithms-modules/algorithms-miscellaneous-1/pom.xml +++ b/algorithms-modules/algorithms-miscellaneous-1/pom.xml @@ -63,10 +63,7 @@ - 3.6.1 - 1.11 3.3.0 - 2.7 \ No newline at end of file diff --git a/algorithms-modules/algorithms-miscellaneous-2/pom.xml b/algorithms-modules/algorithms-miscellaneous-2/pom.xml index f3b41cb7f8..ca14533e82 100644 --- a/algorithms-modules/algorithms-miscellaneous-2/pom.xml +++ b/algorithms-modules/algorithms-miscellaneous-2/pom.xml @@ -68,12 +68,8 @@ - 3.6.1 - 1.0.1 1.0.1 1.0.1 - 1.11 - 2.7 \ No newline at end of file diff --git a/algorithms-modules/algorithms-miscellaneous-5/pom.xml b/algorithms-modules/algorithms-miscellaneous-5/pom.xml index 26b445555b..97c61cb88f 100644 --- a/algorithms-modules/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-modules/algorithms-miscellaneous-5/pom.xml @@ -36,10 +36,4 @@
- - 1.0.1 - 1.11 - 3.6.1 - - \ No newline at end of file diff --git a/algorithms-modules/algorithms-miscellaneous-6/pom.xml b/algorithms-modules/algorithms-miscellaneous-6/pom.xml index 34eae2e2b9..5759b2cc6e 100644 --- a/algorithms-modules/algorithms-miscellaneous-6/pom.xml +++ b/algorithms-modules/algorithms-miscellaneous-6/pom.xml @@ -32,8 +32,4 @@
- - 3.6.1 - - \ No newline at end of file diff --git a/algorithms-modules/algorithms-sorting-2/pom.xml b/algorithms-modules/algorithms-sorting-2/pom.xml index d81df0adec..d0f3bdb76f 100644 --- a/algorithms-modules/algorithms-sorting-2/pom.xml +++ b/algorithms-modules/algorithms-sorting-2/pom.xml @@ -31,9 +31,4 @@ - - 3.6.1 - 1.11 - - \ No newline at end of file diff --git a/algorithms-modules/algorithms-sorting/pom.xml b/algorithms-modules/algorithms-sorting/pom.xml index eeccbf814d..f3ce3fc020 100644 --- a/algorithms-modules/algorithms-sorting/pom.xml +++ b/algorithms-modules/algorithms-sorting/pom.xml @@ -32,9 +32,4 @@ - - 3.6.1 - 1.11 - - \ No newline at end of file diff --git a/algorithms-modules/pom.xml b/algorithms-modules/pom.xml index 4a5f36c944..342662ce9c 100644 --- a/algorithms-modules/pom.xml +++ b/algorithms-modules/pom.xml @@ -27,4 +27,11 @@ algorithms-sorting-2 + + 1.11 + 3.6.1 + 2.7 + 1.0.1 + + \ No newline at end of file diff --git a/aws-modules/aws-lambda/lambda/pom.xml b/aws-modules/aws-lambda/lambda/pom.xml index 8bfe7a0ade..edf52d0581 100644 --- a/aws-modules/aws-lambda/lambda/pom.xml +++ b/aws-modules/aws-lambda/lambda/pom.xml @@ -98,8 +98,6 @@ 1.3.0 1.2.0 2.8.2 - 1.11.241 - 3.0.0 \ No newline at end of file diff --git a/aws-modules/aws-miscellaneous/pom.xml b/aws-modules/aws-miscellaneous/pom.xml index 888a2a561f..2b07f1153b 100644 --- a/aws-modules/aws-miscellaneous/pom.xml +++ b/aws-modules/aws-miscellaneous/pom.xml @@ -112,12 +112,10 @@ 1.3.0 1.1.0 2.8.0 - 1.11.290 1.11.86 https://s3-us-west-2.amazonaws.com/dynamodb-local/release 1.10.L001 0.9.4.0006L - 3.0.0 3.1.1 diff --git a/aws-modules/aws-s3/pom.xml b/aws-modules/aws-s3/pom.xml index e7e04782b1..0ea99588d8 100644 --- a/aws-modules/aws-s3/pom.xml +++ b/aws-modules/aws-s3/pom.xml @@ -60,10 +60,8 @@ - 1.11.290 1.10.L001 0.9.4.0006L - 3.0.0 \ No newline at end of file diff --git a/aws-modules/pom.xml b/aws-modules/pom.xml index 3c5459d46c..601b1350bc 100644 --- a/aws-modules/pom.xml +++ b/aws-modules/pom.xml @@ -21,4 +21,8 @@ aws-s3 + + 1.11.290 + 3.0.0 + \ No newline at end of file From 98c81c1d08cd742ca418672594010a781bdc5673 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Sun, 28 Aug 2022 18:42:36 +0530 Subject: [PATCH 32/35] JAVA-13746 testing-modules parallel-tests-junit not running in parallel (#12655) --- testing-modules/parallel-tests-junit/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testing-modules/parallel-tests-junit/pom.xml b/testing-modules/parallel-tests-junit/pom.xml index f5a46b91e3..8b1491fd75 100644 --- a/testing-modules/parallel-tests-junit/pom.xml +++ b/testing-modules/parallel-tests-junit/pom.xml @@ -19,5 +19,9 @@ math-test-functions string-test-functions + + + 2.21.0 + \ No newline at end of file From 15581547df1d369828f3dc6e6cf19a5a7ed51ac6 Mon Sep 17 00:00:00 2001 From: Azhwani <13301425+azhwani@users.noreply.github.com> Date: Sun, 28 Aug 2022 18:53:06 +0200 Subject: [PATCH 33/35] BAEL-5390: Compare Characters in Java (#12633) * BAEL-5390: Compare Characters in Java * create new module core-java-string-operations-5 --- .../core-java-string-operations-5/README.md | 2 + .../core-java-string-operations-5/pom.xml | 35 ++++++++++++ .../CharComparisonUnitTest.java | 55 +++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 core-java-modules/core-java-string-operations-5/README.md create mode 100644 core-java-modules/core-java-string-operations-5/pom.xml create mode 100644 core-java-modules/core-java-string-operations-5/src/test/java/com/baeldung/charcomparison/CharComparisonUnitTest.java diff --git a/core-java-modules/core-java-string-operations-5/README.md b/core-java-modules/core-java-string-operations-5/README.md new file mode 100644 index 0000000000..a96ddccabb --- /dev/null +++ b/core-java-modules/core-java-string-operations-5/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: + diff --git a/core-java-modules/core-java-string-operations-5/pom.xml b/core-java-modules/core-java-string-operations-5/pom.xml new file mode 100644 index 0000000000..a0c630cb0f --- /dev/null +++ b/core-java-modules/core-java-string-operations-5/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + core-java-string-operations-5 + 0.1.0-SNAPSHOT + core-java-string-operations-5 + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + + 11 + 11 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-string-operations-5/src/test/java/com/baeldung/charcomparison/CharComparisonUnitTest.java b/core-java-modules/core-java-string-operations-5/src/test/java/com/baeldung/charcomparison/CharComparisonUnitTest.java new file mode 100644 index 0000000000..e0f5bffbea --- /dev/null +++ b/core-java-modules/core-java-string-operations-5/src/test/java/com/baeldung/charcomparison/CharComparisonUnitTest.java @@ -0,0 +1,55 @@ +package com.baeldung.charcomparison; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Objects; + +import org.junit.jupiter.api.Test; + +class CharComparisonUnitTest { + + @Test + void givenTwoPrimitiveChars_whenUsingRelationalOperators_thenCompare() { + assertFalse('a' == 'A'); + assertTrue('a' < 'v'); + assertTrue('F' > 'D'); + } + + @Test + void givenTwoPrimitiveChars_whenUsingCompareMethod_thenCompare() { + assertTrue(Character.compare('C', 'C') == 0); + assertTrue(Character.compare('f', 'A') > 0); + assertTrue(Character.compare('Y', 'z') < 0); + } + + @Test + void givenTwoCharObjects_whenUsingCompareToMethod_thenCompare() { + Character chK = Character.valueOf('K'); + Character chG = Character.valueOf('G'); + Character chH = Character.valueOf('H'); + + assertTrue(chK.compareTo(chK) == 0); + assertTrue(chK.compareTo(chG) > 0); + assertTrue(chG.compareTo(chH) < 0); + } + + @Test + void givenTwoCharObjects_whenUsingEqualsMethod_thenCompare() { + Character chL = 'L'; + Character chV = 'V'; + + assertTrue(chL.equals(chL)); + assertFalse(chL.equals(chV)); + } + + @Test + void givenTwoCharObjects_whenUsingObjectsEqualsMethod_thenCompare() { + Character chA = 'A'; + Character chB = 'B'; + + assertTrue(Objects.equals(chA, chA)); + assertFalse(Objects.equals(chA, chB)); + } + +} From 78b7c6dcf87187d8e260e3c3b962d3e36bc80b1f Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Tue, 30 Aug 2022 02:08:50 +0200 Subject: [PATCH 34/35] Make Division of Two Integers Result in a Float (#12658) --- .../intdivision/IntegerDivisionUnitTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/intdivision/IntegerDivisionUnitTest.java diff --git a/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/intdivision/IntegerDivisionUnitTest.java b/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/intdivision/IntegerDivisionUnitTest.java new file mode 100644 index 0000000000..46527575e9 --- /dev/null +++ b/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/intdivision/IntegerDivisionUnitTest.java @@ -0,0 +1,26 @@ +package com.baeldung.intdivision; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +class IntegerDivisionUnitTest { + @Test + void givenTwoInt_whenExecDivision_shouldGetInteger() { + int i = 10 / 4; + assertEquals(2, i); + + float x = 10 / 4; + assertEquals(2, x); + } + + @Test + void givenTwoInt_whenCastAnyoneToFloat_shouldGetFloatResult() { + float x = (float) 10 / 4; + assertEquals(2.5, x); + + float y = 10 / (float) 8; + assertEquals(1.25, y); + } + +} From 72daf776664ad0ac15226349751b592b1afb9f08 Mon Sep 17 00:00:00 2001 From: vunamtien Date: Tue, 30 Aug 2022 20:51:01 +0700 Subject: [PATCH 35/35] BAEL-5615-gen-md5-checksum-of-file (#12668) Co-authored-by: tienvn4 --- core-java-modules/core-java-io-4/pom.xml | 10 +++++ .../md5checksum/Md5ChecksumGenerator.java | 44 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 core-java-modules/core-java-io-4/src/main/java/com/baeldung/md5checksum/Md5ChecksumGenerator.java diff --git a/core-java-modules/core-java-io-4/pom.xml b/core-java-modules/core-java-io-4/pom.xml index 9fc00ff586..2cc05698fc 100644 --- a/core-java-modules/core-java-io-4/pom.xml +++ b/core-java-modules/core-java-io-4/pom.xml @@ -32,6 +32,16 @@ log4j-over-slf4j ${org.slf4j.version} + + commons-codec + commons-codec + 1.15 + + + com.google.guava + guava + 31.1-jre + \ No newline at end of file diff --git a/core-java-modules/core-java-io-4/src/main/java/com/baeldung/md5checksum/Md5ChecksumGenerator.java b/core-java-modules/core-java-io-4/src/main/java/com/baeldung/md5checksum/Md5ChecksumGenerator.java new file mode 100644 index 0000000000..11c83591eb --- /dev/null +++ b/core-java-modules/core-java-io-4/src/main/java/com/baeldung/md5checksum/Md5ChecksumGenerator.java @@ -0,0 +1,44 @@ +package com.baeldung.md5checksum; + +import com.google.common.hash.HashCode; +import com.google.common.hash.Hashing; +import com.google.common.io.ByteSource; +import org.apache.commons.codec.digest.DigestUtils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigInteger; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class Md5ChecksumGenerator { + + public static String genWithApacheCommons(String filePath) throws IOException { + try (InputStream is = Files.newInputStream(Paths.get(filePath))) { + return DigestUtils.md5Hex(is); + } + } + + public static String genWithGuava(String filePath) throws IOException { + File file = new File(filePath); + ByteSource byteSource = com.google.common.io.Files.asByteSource(file); + HashCode hc = byteSource.hash(Hashing.md5()); + return hc.toString(); + } + + public static String genWithMessageDigest(String filePath) throws IOException, NoSuchAlgorithmException { + byte[] data = Files.readAllBytes(Paths.get(filePath)); + byte[] hash = MessageDigest.getInstance("MD5").digest(data); + return new BigInteger(1, hash).toString(16); + } + + public static void main(String[] args) throws IOException, NoSuchAlgorithmException { + String filePath = "D:\\temp.txt"; + System.out.println(genWithApacheCommons(filePath)); + System.out.println(genWithMessageDigest(filePath)); + System.out.println(genWithGuava(filePath)); + } +}