feat(trade): 添加快递客户端专用 RestTemplate 配置
- 在 ExpressClientConfig 中定义了名为 expressRestTemplate 的 RestTemplate Bean- 使用 @Qualifier 注解标识该 RestTemplate 用于快递客户端 - 更新 ExpressClientFactoryImpl以使用指定的 expressRestTemplate - 引入 @Qualifier 注解确保依赖注入的准确性pull/214/head
parent
d64f4e9343
commit
84703c6d80
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.framework.delivery.config;
|
|||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.ExpressClientFactoryImpl;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
|
@ -18,6 +19,11 @@ import org.springframework.web.client.RestTemplate;
|
|||
@Configuration(proxyBeanMethods = false)
|
||||
public class ExpressClientConfig {
|
||||
|
||||
@Bean
|
||||
@Qualifier("expressRestTemplate")
|
||||
public RestTemplate expressRestTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
@Bean
|
||||
public ExpressClientFactory expressClientFactory(TradeExpressProperties tradeExpressProperties,
|
||||
RestTemplate restTemplate) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100.K
|
|||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao.KdNiaoExpressClient;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -24,6 +25,7 @@ public class ExpressClientFactoryImpl implements ExpressClientFactory {
|
|||
private final Map<ExpressClientEnum, ExpressClient> clientMap = new ConcurrentHashMap<>(8);
|
||||
|
||||
private final TradeExpressProperties tradeExpressProperties;
|
||||
@Qualifier("expressRestTemplate")
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue