gpt4 book ai didi

java.lang.NoClassDefFoundError : org/apache/http/conn/scheme/SchemeSocketFactory 错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:41:05 25 4
gpt4 key购买 nike

我正尝试通过 AWSCredentials 发送邮件但出现异常

java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SchemeSocketFactory

我添加了这些 jar :

  • 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-flow-build-tools-1.3.11.jar
  • commons-logging.jar
  • httpclient-4.0-alpha4.jar
  • httpcore-4.0-alpha6.jar
  • log4j-1.2.13.jar
  • 邮件.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 = "support@brandzter.com"; // should be verified email

LinkedList<String> recipients = new LinkedList<String>();
recipients.add("khoyendra@globussoft.com"); // 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 但没有找到。我不确定是否使用了错误的 jar 。谁能告诉我问题出在哪里?

我是

最佳答案

来自javadocs , SchemeSocketFactory 类仅在 4.1 版后可用。所以这可能与您使用的是 4.0 alpha jar 这一事实有关。尝试将您的 http 客户端库升级到 4.1 或更高版本。

关于java.lang.NoClassDefFoundError : org/apache/http/conn/scheme/SchemeSocketFactory 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11151519/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com