refactor(core): restClientBuilder 抽取到 common-core 包
Some checks failed
同步代码 / gitcode (push) Has been cancelled
同步代码 / gitlink (push) Has been cancelled
同步代码 / gitee (push) Has been cancelled

This commit is contained in:
冷冷 2024-09-08 08:24:24 +08:00
parent 5b2684b33d
commit 0200b92178
2 changed files with 12 additions and 13 deletions

View File

@ -20,6 +20,7 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
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;
/**
@ -40,4 +41,15 @@ public class RestTemplateConfiguration {
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();
}
}

View File

@ -8,8 +8,6 @@ import com.pig4cloud.pig.common.excel.provider.RemoteDictDataProvider;
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;
@ -26,17 +24,6 @@ import java.util.Optional;
@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 }