sendgrid java,Sendgrid的Java不在Maven的工作

sendgrid java,Sendgrid的Java不在Maven的工作Iamusinghttp github com sendgrid sendgrid javainmyapp WhenItriedto javaitscausi lang NoClassDefFo

sendgrid java,Sendgrid的Java不在Maven的工作

I am using https://github.com/sendgrid/sendgrid-java in my app. When I tried to run a sendgridexample.java its causing error InvocationTargetException and the root cause is

java.lang.NoClassDefFoundError: org/apache/http/impl/client/HttpClientBuilder

com.sendgrid.SendGrid.(SendGrid.java:80)

I am using maven. Is there anyone tried this in maven. I tried reaching the sendgrid support team but still didn’t get any update regarding this. Can any one tell what is wrong with my code. Thanks in advance.

SendGrid sendgrid = new SendGrid(“API_KEY”);

SendGrid.Email email = new SendGrid.Email();

email.addTo(“”);

email.setFrom(“”);

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);

}

解决方案

Yes, I have found a solution. Go to https://github.com/sendgrid/sendgrid-java/tree/master/src/main/java/com/sendgrid. Copy the two java file[SendGrid.java and SendGridException.java] and create a folder com.sendgrid in your application and paste these two java file inside that folder. Then go to https://github.com/sendgrid/sendgrid-java/blob/master/pom.xml. Copy all the dependency for these two java file and paste in your pom.xml file. It will work fine.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/233210.html原文链接:https://javaforall.net

(0)
上一篇 2025年8月7日 上午10:01
下一篇 2025年8月7日 上午10:22


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号