From 84703c6d80cd103f6d2139da788b0e9450ee4534 Mon Sep 17 00:00:00 2001 From: wuKong Date: Fri, 31 Oct 2025 10:35:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(trade):=20=E6=B7=BB=E5=8A=A0=E5=BF=AB?= =?UTF-8?q?=E9=80=92=E5=AE=A2=E6=88=B7=E7=AB=AF=E4=B8=93=E7=94=A8=20RestTe?= =?UTF-8?q?mplate=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 ExpressClientConfig 中定义了名为 expressRestTemplate 的 RestTemplate Bean- 使用 @Qualifier 注解标识该 RestTemplate 用于快递客户端 - 更新 ExpressClientFactoryImpl以使用指定的 expressRestTemplate - 引入 @Qualifier 注解确保依赖注入的准确性 --- .../framework/delivery/config/ExpressClientConfig.java | 6 ++++++ .../delivery/core/client/impl/ExpressClientFactoryImpl.java | 2 ++ 2 files changed, 8 insertions(+) diff --git a/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java b/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java index 2799c3f1c..2f04c7fb6 100644 --- a/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java +++ b/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java @@ -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) { diff --git a/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java b/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java index 2cd523c2b..8438c5979 100644 --- a/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java +++ b/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java @@ -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 clientMap = new ConcurrentHashMap<>(8); private final TradeExpressProperties tradeExpressProperties; + @Qualifier("expressRestTemplate") private final RestTemplate restTemplate; @Override