From d25250894a5fb334d79757e81c20b5c60b7bafd3 Mon Sep 17 00:00:00 2001 From: Robert McNees <86265089+robertmcnees@users.noreply.github.com> Date: Thu, 9 May 2024 10:27:48 -0400 Subject: [PATCH] Updated dependencies to match what is provided from Spring Initializr (#23) --- README.adoc | 19 +++---------------- complete/build.gradle | 4 +--- complete/pom.xml | 13 ++++++------- complete/src/main/resources/application.yml | 2 +- .../test/java/gateway/ApplicationTest.java | 1 - initial/build.gradle | 3 ++- initial/pom.xml | 7 ++++++- 7 files changed, 19 insertions(+), 30 deletions(-) diff --git a/README.adoc b/README.adoc index bbf224a..9299ae0 100644 --- a/README.adoc +++ b/README.adoc @@ -11,8 +11,9 @@ You will build a gateway using https://cloud.spring.io/spring-cloud-gateway/[Spr == What You Need -:java_version: 1.8 -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/prereq_editor_jdk_buildtools.adoc[] +* About 15 minutes +* A favorite text editor or IDE +* https://www.oracle.com/java/technologies/downloads/[Java 17+] include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/how_to_complete_this_guide.adoc[] @@ -114,20 +115,6 @@ in circuit breakers. You can do so in the Spring Cloud Gateway by using the Resi This is implemented through a simple filter that you can add to your requests. We can create another route to demonstrate this. -To use this filter you need to add the reactive Resilience4J CircuitBreaker dependency to your classpath. - -`pom.xml` -[source,java,tabsize=2] ----- -include::complete/pom.xml[tags=dependency] ----- - -`build.gradle` -[source,java,tabsize=2] ----- -include::complete/build.gradle[tags=dependency] ----- - In the next example, we use HTTPBin's delay API, which waits a certain number of seconds before sending a response. Since this API could potentially take a long time to send its response, we can wrap the route that uses this API in a circuit breaker. diff --git a/complete/build.gradle b/complete/build.gradle index 0096c38..98fce62 100644 --- a/complete/build.gradle +++ b/complete/build.gradle @@ -21,12 +21,10 @@ ext { } dependencies { - implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j' - // tag::dependency[] implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-reactor-resilience4j' - // end::dependency[] implementation 'org.springframework.cloud:spring-cloud-starter-gateway' testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'io.projectreactor:reactor-test' testImplementation 'org.springframework.cloud:spring-cloud-starter-contract-stub-runner' } diff --git a/complete/pom.xml b/complete/pom.xml index 07be9b2..f7a7102 100644 --- a/complete/pom.xml +++ b/complete/pom.xml @@ -20,14 +20,8 @@ org.springframework.cloud - spring-cloud-starter-circuitbreaker-resilience4j + spring-cloud-starter-circuitbreaker-reactor-resilience4j - - - org.springframework.cloud - spring-cloud-starter-circuitbreaker-reactor-resilience4j - - org.springframework.cloud spring-cloud-starter-gateway @@ -38,6 +32,11 @@ spring-boot-starter-test test + + io.projectreactor + reactor-test + test + org.springframework.cloud spring-cloud-starter-contract-stub-runner diff --git a/complete/src/main/resources/application.yml b/complete/src/main/resources/application.yml index 19020a3..47fbb02 100644 --- a/complete/src/main/resources/application.yml +++ b/complete/src/main/resources/application.yml @@ -1,2 +1,2 @@ server: - port: 9999 \ No newline at end of file + port: 8080 \ No newline at end of file diff --git a/complete/src/test/java/gateway/ApplicationTest.java b/complete/src/test/java/gateway/ApplicationTest.java index a0ed9e9..e1c5ac0 100644 --- a/complete/src/test/java/gateway/ApplicationTest.java +++ b/complete/src/test/java/gateway/ApplicationTest.java @@ -5,7 +5,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.reactive.server.WebTestClient; import static com.github.tomakehurst.wiremock.client.WireMock.*; diff --git a/initial/build.gradle b/initial/build.gradle index 8aa45d4..98fce62 100644 --- a/initial/build.gradle +++ b/initial/build.gradle @@ -21,9 +21,10 @@ ext { } dependencies { - implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j' + implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-reactor-resilience4j' implementation 'org.springframework.cloud:spring-cloud-starter-gateway' testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'io.projectreactor:reactor-test' testImplementation 'org.springframework.cloud:spring-cloud-starter-contract-stub-runner' } diff --git a/initial/pom.xml b/initial/pom.xml index 52c0569..f7a7102 100644 --- a/initial/pom.xml +++ b/initial/pom.xml @@ -20,7 +20,7 @@ org.springframework.cloud - spring-cloud-starter-circuitbreaker-resilience4j + spring-cloud-starter-circuitbreaker-reactor-resilience4j org.springframework.cloud @@ -32,6 +32,11 @@ spring-boot-starter-test test + + io.projectreactor + reactor-test + test + org.springframework.cloud spring-cloud-starter-contract-stub-runner