【发布时间】:2018-03-18 01:15:05
【问题描述】:
我想在 AWS EC2 ubuntu 实例上的 java 应用程序中添加邮件发送功能。我的邮件地址已经在 SES 仪表板中注册并得到验证。 EC2 实例位于爱尔兰的欧盟西部地区,因此 AWS SES 应该可用,因为有文档。
我从 AWSJavaSDK 文档中获取了这个示例代码:
AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.standard().build();
SendEmailRequest request = new SendEmailRequest()
.withSource("sender@example.com")
.withDestination(
new Destination().withToAddresses("recipient1@example.com", "recipient2@example.com").withCcAddresses("recipient3@example.com")
.withBccAddresses(new ArrayList()))
.withMessage(
new Message()
.withSubject(new Content().withData("Test email").withCharset("UTF-8"))
.withBody(
new Body()
.withText(new Content().withData("This is the message body in text format.").withCharset("UTF-8"))))
.withReplyToAddresses(new ArrayList()).withReturnPath("").withSourceArn("").withReturnPathArn("");
SendEmailResult response = client.sendEmail(request);
我还将此依赖项包含在我的 pom.xml 中:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-ses</artifactId>
<version>1.11.296</version>
</dependency>
我得到的错误信息是:
线程“主”java.lang.NoClassDefFoundError 中的异常: com/amazonaws/services/simpleemail/AmazonSimpleEmailServiceClientBuilder
引起:java.lang.ClassNotFoundException: com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder
当我在本地启动我的应用程序时,只会出现找不到区域但查找类没有问题的异常。
为什么在 EC2 实例上找不到类 AmazonSimpleEmailServiceClientBuilder?
【问题讨论】:
标签: java amazon-web-services amazon-ec2 aws-sdk