From b55d24b58e8305dc6a93f965d56a0c526925f6b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?WangLiang/=E7=8E=8B=E8=89=AF?= <841369634@qq.com>
Date: Sun, 11 Apr 2021 14:58:07 +0800
Subject: [PATCH] optimize: make `LoadBalanceProperties` compatible with
 `spring-boot:2.x` and above (#3601)

---
 changes/1.5.0.md                              |  1 +
 changes/en-us/1.5.0.md                        |  1 +
 .../boot/autoconfigure/StarterConstants.java  |  1 +
 .../registry/LoadBalanceProperties.java       |  4 +--
 ...itional-spring-configuration-metadata.json | 26 +++++++++++++++++--
 5 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/changes/1.5.0.md b/changes/1.5.0.md
index a4d035e66..95812fa17 100644
--- a/changes/1.5.0.md
+++ b/changes/1.5.0.md
@@ -85,6 +85,7 @@ Seata 鏄竴娆惧紑婧愮殑鍒嗗竷寮忎簨鍔¤В鍐虫柟妗堬紝鎻愪緵楂樻€ц兘鍜岀畝鍗�
   - [[#3549](https://github.com/seata/seata/pull/3549)] 缁熶竴涓嶅悓琛ㄤ腑鐨剎id瀛楁鐨勯暱搴�
   - [[#3551](https://github.com/seata/seata/pull/3551)] 璋冨ぇRETRY_DEAD_THRESHOLD鐨勫€间互鍙婅缃垚鍙厤缃�
   - [[#3589](https://github.com/seata/seata/pull/3589)] 浣跨敤JUnit API鍋氬紓甯告鏌�
+  - [[#3601](https://github.com/seata/seata/pull/3601)] 浣縛LoadBalanceProperties`涓巂spring-boot:2.x`鍙婁互涓婄増鏈吋瀹�
 
 
   ### test
diff --git a/changes/en-us/1.5.0.md b/changes/en-us/1.5.0.md
index c070e13c3..640b9ea6e 100644
--- a/changes/en-us/1.5.0.md
+++ b/changes/en-us/1.5.0.md
@@ -86,6 +86,7 @@
   - [[#3549](https://github.com/seata/seata/pull/3549)] unified the length of xid in scripts
   - [[#3551](https://github.com/seata/seata/pull/3551)] make RETRY_DEAD_THRESHOLD bigger and configurable
   - [[#3589](https://github.com/seata/seata/pull/3589)] Changed exception check by JUnit API usage
+  - [[#3601](https://github.com/seata/seata/pull/3601)] make `LoadBalanceProperties` compatible with `spring-boot:2.x` and above
 
   ### test	
 
diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java
index 2ce2a16d0..c7ee8b983 100644
--- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java
+++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java
@@ -33,6 +33,7 @@ public interface StarterConstants {
     String CLIENT_TM_PREFIX = CLIENT_PREFIX + ".tm";
     String LOCK_PREFIX = CLIENT_RM_PREFIX + ".lock";
     String UNDO_PREFIX = CLIENT_PREFIX + ".undo";
+    String LOAD_BALANCE_PREFIX_KEBAB_STYLE = CLIENT_PREFIX + ".load-balance";
     String LOAD_BALANCE_PREFIX = CLIENT_PREFIX + ".loadBalance";
     String LOG_PREFIX = SEATA_PREFIX + ".log";
     String COMPRESS_PREFIX = UNDO_PREFIX + ".compress";
diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/LoadBalanceProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/LoadBalanceProperties.java
index e5d46ec1a..e2bfb35d9 100644
--- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/LoadBalanceProperties.java
+++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/LoadBalanceProperties.java
@@ -20,13 +20,13 @@ import org.springframework.stereotype.Component;
 
 import static io.seata.common.DefaultValues.DEFAULT_LOAD_BALANCE;
 import static io.seata.common.DefaultValues.VIRTUAL_NODES_DEFAULT;
-import static io.seata.spring.boot.autoconfigure.StarterConstants.LOAD_BALANCE_PREFIX;
+import static io.seata.spring.boot.autoconfigure.StarterConstants.LOAD_BALANCE_PREFIX_KEBAB_STYLE;
 
 /**
  * @author ls9527
  */
 @Component
-@ConfigurationProperties(prefix = LOAD_BALANCE_PREFIX)
+@ConfigurationProperties(prefix = LOAD_BALANCE_PREFIX_KEBAB_STYLE)
 public class LoadBalanceProperties {
     /**
      * the load balance
diff --git a/seata-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/seata-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index 0b7661729..b9e020576 100644
--- a/seata-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/seata-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -187,7 +187,7 @@
       "deprecation": {
         "level": "error",
         "replacement": "seata.log.exception-rate",
-        "reason": "The location of this configuration has been changed to 'seata.log.exception-rate'."
+        "reason": "Please configure to 'seata.log.exception-rate'."
       }
     },
     {
@@ -268,6 +268,28 @@
       "sourceType": "io.seata.spring.boot.autoconfigure.properties.client.ThreadFactoryProperties",
       "defaultValue": 1
     },
+    {
+      "name": "seata.registry.load-balance",
+      "type": "java.lang.String",
+      "sourceType": "io.seata.spring.boot.autoconfigure.properties.registry.RegistryProperties",
+      "defaultValue": "RandomLoadBalance",
+      "deprecation": {
+        "level": "error",
+        "replacement": "seata.client.load-balance.type",
+        "reason": "Please configure to 'seata.client.load-balance.type'."
+      }
+    },
+    {
+      "name": "seata.registry.load-balance-virtual-nodes",
+      "type": "java.lang.Integer",
+      "sourceType": "io.seata.spring.boot.autoconfigure.properties.registry.RegistryProperties",
+      "defaultValue": 10,
+      "deprecation": {
+        "level": "error",
+        "replacement": "seata.client.load-balance.virtual-nodes",
+        "reason": "Please configure to 'seata.client.load-balance.virtual-nodes'."
+      }
+    },
     {
       "name": "seata.client.load-balance.type",
       "type": "java.lang.String",
@@ -305,7 +327,7 @@
       ]
     },
     {
-      "name": "seata.registry.load-balance",
+      "name": "seata.client.load-balance.type",
       "values": [
         {
           "value": "RandomLoadBalance",
-- 
GitLab