Skip to content

Commit 0200b92

Browse files
committed
refactor(core): restClientBuilder 抽取到 common-core 包
1 parent 5b2684b commit 0200b92

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/RestTemplateConfiguration.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2121
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
2222
import org.springframework.context.annotation.Bean;
23+
import org.springframework.web.client.RestClient;
2324
import org.springframework.web.client.RestTemplate;
2425

2526
/**
@@ -40,4 +41,15 @@ public RestTemplate restTemplate() {
4041
return new RestTemplate();
4142
}
4243

44+
/**
45+
* REST 客户端构建器(支持负载均衡)
46+
* @return {@link RestClient.Builder }
47+
*/
48+
@Bean
49+
@LoadBalanced
50+
@ConditionalOnProperty(value = "spring.cloud.nacos.discovery.enabled", havingValue = "true", matchIfMissing = true)
51+
RestClient.Builder restClientBuilder() {
52+
return RestClient.builder();
53+
}
54+
4355
}

pig-common/pig-common-excel/src/main/java/com/pig4cloud/pig/common/excel/ExcelAutoConfiguration.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import com.pig4cloud.plugin.excel.handler.DictDataProvider;
99
import org.springframework.boot.autoconfigure.AutoConfiguration;
1010
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
11-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
12-
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
1311
import org.springframework.context.annotation.Bean;
1412
import org.springframework.web.client.RestClient;
1513
import org.springframework.web.client.support.RestClientAdapter;
@@ -26,17 +24,6 @@
2624
@AutoConfiguration
2725
public class ExcelAutoConfiguration {
2826

29-
/**
30-
* REST 客户端构建器(支持负载均衡)
31-
* @return {@link RestClient.Builder }
32-
*/
33-
@Bean
34-
@LoadBalanced
35-
@ConditionalOnProperty(value = "spring.cloud.nacos.discovery.enabled", havingValue = "true", matchIfMissing = true)
36-
RestClient.Builder restClientBuilder() {
37-
return RestClient.builder();
38-
}
39-
4027
/**
4128
* 远程 dict API 服务
4229
* @return {@link RemoteDictApiService }

0 commit comments

Comments
 (0)