diff --git a/accompany-base/accompany-email/accompany-email-service/src/main/java/com/accompany/email/config/TencentSecClientConfig.java b/accompany-base/accompany-email/accompany-email-service/src/main/java/com/accompany/email/config/TencentSecClientConfig.java index c02869650..3714757af 100644 --- a/accompany-base/accompany-email/accompany-email-service/src/main/java/com/accompany/email/config/TencentSecClientConfig.java +++ b/accompany-base/accompany-email/accompany-email-service/src/main/java/com/accompany/email/config/TencentSecClientConfig.java @@ -5,6 +5,7 @@ import com.tencentcloudapi.common.profile.ClientProfile; import com.tencentcloudapi.common.profile.HttpProfile; import com.tencentcloudapi.ses.v20201002.SesClient; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -14,7 +15,7 @@ public class TencentSecClientConfig { @Autowired private TencentSesConfig config; - @Bean + @Bean(name = "sesCredential") public Credential credential() { /* 必要步骤: * 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。 @@ -25,7 +26,7 @@ public class TencentSecClientConfig { return new Credential(config.getSecretId(), config.getSecretKey()); } - @Bean + @Bean(name = "sesHttpProfile") public HttpProfile httpProfile() { // 实例化一个http选项,可选,没有特殊需求可以跳过 HttpProfile httpProfile = new HttpProfile(); @@ -44,14 +45,14 @@ public class TencentSecClientConfig { } @Bean - public SesClient sesClient(Credential credential, HttpProfile httpProfile) { + public SesClient sesClient(@Qualifier("sesCredential") Credential credential, @Qualifier("sesHttpProfile") HttpProfile sesHttpProfile) { /* 非必要步骤: * 实例化一个客户端配置对象,可以指定超时时间等配置 */ ClientProfile clientProfile = new ClientProfile(); /* SDK默认用TC3-HMAC-SHA256进行签名 * 非必要请不要修改这个字段 */ clientProfile.setSignMethod("HmacSHA256"); - clientProfile.setHttpProfile(httpProfile); + clientProfile.setHttpProfile(sesHttpProfile); /* 实例化要请求产品(以sms为例)的client对象 * 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,支持的地域列表参考 https://cloud.tencent.com/document/api/382/52071#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 */ //return new SesClient(credential, config.getRegion(), clientProfile); diff --git a/accompany-base/accompany-sms/accompany-sms-service/src/main/java/com/accompany/sms/config/TencentSmsConfiguration.java b/accompany-base/accompany-sms/accompany-sms-service/src/main/java/com/accompany/sms/config/TencentSmsConfiguration.java index b1f4696c2..9b8b2f0de 100644 --- a/accompany-base/accompany-sms/accompany-sms-service/src/main/java/com/accompany/sms/config/TencentSmsConfiguration.java +++ b/accompany-base/accompany-sms/accompany-sms-service/src/main/java/com/accompany/sms/config/TencentSmsConfiguration.java @@ -5,6 +5,7 @@ import com.tencentcloudapi.common.profile.ClientProfile; import com.tencentcloudapi.common.profile.HttpProfile; import com.tencentcloudapi.sms.v20210111.SmsClient; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -19,7 +20,7 @@ public class TencentSmsConfiguration { @Autowired private TencentSmsConfig tencentSmsConfig; - @Bean + @Bean(name = "smsCredential") public Credential credential() { /* 必要步骤: * 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。 @@ -30,7 +31,7 @@ public class TencentSmsConfiguration { return new Credential(tencentSmsConfig.getSecretId(), tencentSmsConfig.getSecretKey()); } - @Bean + @Bean(name = "smsHttpProfile") public HttpProfile httpProfile() { // 实例化一个http选项,可选,没有特殊需求可以跳过 HttpProfile httpProfile = new HttpProfile(); @@ -49,14 +50,14 @@ public class TencentSmsConfiguration { } @Bean - public SmsClient smsClient(Credential credential, HttpProfile httpProfile) { + public SmsClient smsClient(@Qualifier("smsCredential") Credential credential, @Qualifier("smsHttpProfile") HttpProfile smsHttpProfile) { /* 非必要步骤: * 实例化一个客户端配置对象,可以指定超时时间等配置 */ ClientProfile clientProfile = new ClientProfile(); /* SDK默认用TC3-HMAC-SHA256进行签名 * 非必要请不要修改这个字段 */ clientProfile.setSignMethod("HmacSHA256"); - clientProfile.setHttpProfile(httpProfile); + clientProfile.setHttpProfile(smsHttpProfile); /* 实例化要请求产品(以sms为例)的client对象 * 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,支持的地域列表参考 https://cloud.tencent.com/document/api/382/52071#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 */ return new SmsClient(credential, "ap-guangzhou", clientProfile);