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

}

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值