邮件与短信冲突fixed

邮件与短信冲突
This commit is contained in:
2025-06-22 16:52:02 +08:00
parent 230315e0e6
commit da5e7af315
2 changed files with 10 additions and 8 deletions

View File

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

View File

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