我特林通過AWSCredentials發送郵件,但得到一個異常java.lang.NoClassDefFoundError:組織/阿帕奇/ HTTP /康涅狄格州/方案/ SchemeSocketFactory
java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SchemeSocketFactory
我已經添加了這些罐子:
- AWS-java的SDK-1.3.11.jar
- AWS-java的SDK-1.3.11-javadoc.jar
- AWS-java的SDK-1.3.11-sources.jar
- aws- Java的SDK流 - 構建 - 工具 - 1.3.11.jar
- 的commons-logging.jar
- 的HttpClient-4.0-alpha4.jar
- 的HttpCore-4.0-alpha6.jar
- 的log4j-1.2。 13.jar
- 的mail.jar
我的Java代碼 -
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
import com.amazonaws.services.simpleemail.model.*;
import java.util.LinkedList;
public class SESExample {
public static final String ACCESS_KEY = "My Access";
public static final String SECRET_KEY = "My Secret";
public static void main(String args[]) {
String sender = "[email protected]"; // should be verified email
LinkedList<String> recipients = new LinkedList<String>();
recipients.add("[email protected]"); // again a verified email, if you are in sandbox
SendMail(sender, recipients, "Hi", "Hi how are u?");
}
public static void SendMail(String sender, LinkedList<String> recipients, String subject, String body) {
Destination destination = new Destination(recipients);
Content subjectContent = new Content(subject);
Content bodyContent = new Content(body);
Body msgBody = new Body(bodyContent);
Message msg = new Message(subjectContent, msgBody);
SendEmailRequest request = new SendEmailRequest(sender, destination, msg);
AWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY);
AmazonSimpleEmailServiceClient sesClient = new AmazonSimpleEmailServiceClient(credentials);
SendEmailResult result = sesClient.sendEmail(request);
System.out.println(result);
}
}
我也試圖搜索這個罐子,但沒有得到。 我使用錯誤的jar無法確定。 任何人都可以告訴我是什麼問題?
我
你能告訴我們classpath的文件嗎?此行中出現 – Zakaria