【发布时间】:2015-05-17 06:54:14
【问题描述】:
我在我的应用程序中使用https://github.com/sendgrid/sendgrid-java。当我尝试运行 sendgridexample.java 时,它会导致错误 InvocationTargetException,根本原因是
java.lang.NoClassDefFoundError: org/apache/http/impl/client/HttpClientBuilder
com.sendgrid.SendGrid.<init>(SendGrid.java:80)
我正在使用 Maven。有没有人在maven中尝试过这个。我尝试联系 sendgrid 支持团队,但仍然没有得到任何关于此的更新。谁能告诉我的代码有什么问题。提前致谢。
SendGrid sendgrid = new SendGrid("API_KEY");
SendGrid.Email email = new SendGrid.Email();
email.addTo("user@domain.com");
email.setFrom("otheruser@domain.com");
email.setSubject("Hello World");
email.setText("My first email with SendGrid Java!");
try {
SendGrid.Response response = sendgrid.send(email);
System.out.println(response.getMessage());
}
catch (SendGridException e) {
System.err.println(e);
}
【问题讨论】:
-
嗨,您找到解决方案了吗?它是一个Android项目吗?我在这里遇到了类似的问题..谢谢!