Files
spring-boot-microservices-p…/cloud-2026-upgrade/steps/05-refreshable-properties.patch
T

29 lines
1.3 KiB
Diff

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; }
}