Add cloud-2026-upgrade: step-by-step upgrade of the shop to Spring Boot 4.2.0 / Spring Cloud 2026.0.0, with probes

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4HkWoC7hLzk61vZa8
This commit is contained in:
Claude
2026-12-04 08:21:10 +05:30
parent 3c17b13c3f
commit 2ddc181501
59 changed files with 1669 additions and 0 deletions
@@ -0,0 +1,22 @@
diff --git a/pom.xml b/pom.xml
index f28fef1..760dc0e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
- <version>4.1.1</version>
+ <version>4.1.3</version>
<relativePath/>
</parent>
@@ -17,7 +17,7 @@
<properties>
<java.version>21</java.version>
- <spring-cloud.version>2025.1.3</spring-cloud.version>
+ <spring-cloud.version>2025.1.5</spring-cloud.version>
</properties>
<modules>
@@ -0,0 +1,22 @@
diff --git a/pom.xml b/pom.xml
index 760dc0e..3ed16b9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
- <version>4.1.3</version>
+ <version>4.2.0</version>
<relativePath/>
</parent>
@@ -17,7 +17,7 @@
<properties>
<java.version>21</java.version>
- <spring-cloud.version>2025.1.5</spring-cloud.version>
+ <spring-cloud.version>2026.0.0</spring-cloud.version>
</properties>
<modules>
@@ -0,0 +1,14 @@
diff --git a/config-server/src/main/resources/config/gateway.yml b/config-server/src/main/resources/config/gateway.yml
index 470bee1..fb2907d 100644
--- a/config-server/src/main/resources/config/gateway.yml
+++ b/config-server/src/main/resources/config/gateway.yml
@@ -4,6 +4,9 @@ spring:
gateway:
server:
webmvc:
+ # Regex matched against the caller's IP AND every address in X-Forwarded-For / Forwarded for=.
+ # Empty (the default here) switches the forwarding filters off: nothing is forwarded upstream.
+ trusted-proxies: ${TRUSTED_PROXIES:}
routes:
- id: products
uri: lb://product-service
@@ -0,0 +1,54 @@
diff --git a/config-server/pom.xml b/config-server/pom.xml
index 5d4c296..4c66381 100644
--- a/config-server/pom.xml
+++ b/config-server/pom.xml
@@ -18,6 +18,21 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
+ <!-- POST /monitor, and (without Spring Cloud Bus on the classpath) the new HttpPropertyPathNotifier -->
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-config-monitor</artifactId>
+ </dependency>
+ <!-- the notifier needs a DiscoveryClient bean ... -->
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+ </dependency>
+ <!-- ... and a RestClient.Builder bean -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-restclient</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/config-server/src/main/resources/application.yml b/config-server/src/main/resources/application.yml
index 1e4ae43..2df2b43 100644
--- a/config-server/src/main/resources/application.yml
+++ b/config-server/src/main/resources/application.yml
@@ -10,3 +10,10 @@ spring:
search-locations: classpath:/config
server:
port: 8888
+eureka:
+ client:
+ service-url:
+ defaultZone: ${EUREKA_URL:http://localhost:8761/eureka}
+ instance:
+ hostname: ${EUREKA_HOSTNAME:localhost}
+ instance-id: ${spring.application.name}:${server.port}
diff --git a/config-server/src/main/resources/config/application.yml b/config-server/src/main/resources/config/application.yml
index a1c6d11..56dedce 100644
--- a/config-server/src/main/resources/config/application.yml
+++ b/config-server/src/main/resources/config/application.yml
@@ -3,7 +3,7 @@ management:
endpoints:
web:
exposure:
- include: health,info,circuitbreakers
+ include: health,info,circuitbreakers,refresh
tracing:
sampling:
probability: 1.0
@@ -0,0 +1,28 @@
diff --git a/order-service/src/main/java/com/ankurm/shop/order/OrderProperties.java b/order-service/src/main/java/com/ankurm/shop/order/OrderProperties.java
index 773028b..38e747f 100644
--- a/order-service/src/main/java/com/ankurm/shop/order/OrderProperties.java
+++ b/order-service/src/main/java/com/ankurm/shop/order/OrderProperties.java
@@ -2,7 +2,21 @@ package com.ankurm.shop.order;
import org.springframework.boot.context.properties.ConfigurationProperties;
-/** Bound from shop.order.* , which comes from the config server (order-service.yml). */
+/**
+ * Bound from shop.order.* , which comes from the config server (order-service.yml).
+ * A class with setters, not a record: a refresh can only re-bind values into an object it can mutate.
+ */
@ConfigurationProperties("shop.order")
-record OrderProperties(String currency, int maxQuantity) {
+class OrderProperties {
+ private String currency;
+ private int maxQuantity;
+
+ public void setCurrency(String currency) { this.currency = currency; }
+ public void setMaxQuantity(int maxQuantity) { this.maxQuantity = maxQuantity; }
+ public String getCurrency() { return currency; }
+ public int getMaxQuantity() { return maxQuantity; }
+
+ // the accessor names the rest of the service already uses
+ String currency() { return currency; }
+ int maxQuantity() { return maxQuantity; }
}