|
|
@@ -7,6 +7,7 @@ import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
|
|
|
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
|
|
|
import software.amazon.awssdk.regions.Region;
|
|
|
import software.amazon.awssdk.services.ses.SesClient;
|
|
|
+import software.amazon.awssdk.services.ses.SesClientBuilder;
|
|
|
|
|
|
/**
|
|
|
* AWS SES配置类
|
|
|
@@ -43,6 +44,11 @@ public class AwsSesConfig {
|
|
|
private String charset = "UTF-8";
|
|
|
|
|
|
/**
|
|
|
+ * 端点URL (用于LocalStack等本地开发环境)
|
|
|
+ */
|
|
|
+ private String endpointUrl;
|
|
|
+
|
|
|
+ /**
|
|
|
* 创建SES客户端
|
|
|
*
|
|
|
* @return SesClient实例
|
|
|
@@ -51,10 +57,16 @@ public class AwsSesConfig {
|
|
|
public SesClient sesClient() {
|
|
|
AwsBasicCredentials awsCreds = AwsBasicCredentials.create(accessKeyId, secretAccessKey);
|
|
|
|
|
|
- return SesClient.builder()
|
|
|
+ SesClientBuilder builder = SesClient.builder()
|
|
|
.region(Region.of(region))
|
|
|
- .credentialsProvider(StaticCredentialsProvider.create(awsCreds))
|
|
|
- .build();
|
|
|
+ .credentialsProvider(StaticCredentialsProvider.create(awsCreds));
|
|
|
+
|
|
|
+ // 如果配置了端点URL,则使用自定义端点(用于LocalStack)
|
|
|
+ if (endpointUrl != null && !endpointUrl.trim().isEmpty()) {
|
|
|
+ builder.endpointOverride(java.net.URI.create(endpointUrl));
|
|
|
+ }
|
|
|
+
|
|
|
+ return builder.build();
|
|
|
}
|
|
|
|
|
|
// Getter和Setter方法
|
|
|
@@ -97,4 +109,12 @@ public class AwsSesConfig {
|
|
|
public void setCharset(String charset) {
|
|
|
this.charset = charset;
|
|
|
}
|
|
|
+
|
|
|
+ public String getEndpointUrl() {
|
|
|
+ return endpointUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setEndpointUrl(String endpointUrl) {
|
|
|
+ this.endpointUrl = endpointUrl;
|
|
|
+ }
|
|
|
}
|