Skip to content

Commit

Permalink
refactor(core): restClientBuilder 抽取到 common-core 包
Browse files Browse the repository at this point in the history
  • Loading branch information
lltx committed Sep 8, 2024
1 parent 5b2684b commit 0200b92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestTemplate;

/**
Expand All @@ -40,4 +41,15 @@ public RestTemplate restTemplate() {
return new RestTemplate();
}

/**
* REST 客户端构建器(支持负载均衡)
* @return {@link RestClient.Builder }
*/
@Bean
@LoadBalanced
@ConditionalOnProperty(value = "spring.cloud.nacos.discovery.enabled", havingValue = "true", matchIfMissing = true)
RestClient.Builder restClientBuilder() {
return RestClient.builder();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import com.pig4cloud.plugin.excel.handler.DictDataProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.support.RestClientAdapter;
Expand All @@ -26,17 +24,6 @@
@AutoConfiguration
public class ExcelAutoConfiguration {

/**
* REST 客户端构建器(支持负载均衡)
* @return {@link RestClient.Builder }
*/
@Bean
@LoadBalanced
@ConditionalOnProperty(value = "spring.cloud.nacos.discovery.enabled", havingValue = "true", matchIfMissing = true)
RestClient.Builder restClientBuilder() {
return RestClient.builder();
}

/**
* 远程 dict API 服务
* @return {@link RemoteDictApiService }
Expand Down

0 comments on commit 0200b92

Please sign in to comment.