Sendgrid的Java不在Maven的工作 [英] Sendgrid Java Not working in Maven

查看:807
本文介绍了Sendgrid的Java不在Maven的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 https://github.com/sendgrid/sendgrid-java 在我应用程序。当我试图运行sendgridexample.java其造成误差的InvocationTargetException和根本原因是

java.lang.NoClassDefFoundError的:组织/阿帕奇/ HTTP / IMPL /客户/ HttpClientBuilder
    com.sendgrid.SendGrid<&初始化GT;(SendGrid.java:80)

我使用maven。是否有任何人在行家试过这个。我试图达到sendgrid支持团队,但仍然没有得到这方面的任何更新。任何一个能告诉什么是错我的code。先谢谢了。

  SendGrid sendgrid =新SendGrid(API_KEY);
SendGrid.Email电子邮件=新SendGrid.Email();email.addTo(user@domain.com);
email.setFrom(otheruser@domain.com);
email.setSubject(的Hello World);
email.setText(我与SendGrid Java的第一封电子邮件!);尝试{
  SendGrid.Response响应= sendgrid.send(电子邮件);
  的System.out.println(response.getMessage());
}
赶上(SendGridException E){
  通信System.err.println(E);
}


解决方案

是的,我已经找到了解决办法。转到 https://github.com/sendgrid / sendgrid-的Java /树/主/ src目录/主/ JAVA / COM / sendgrid 。复制两个Java文件[SendGrid.java和SendGridException.java],并创建应用程序的文件夹com.sendgrid并粘贴文件夹内这两个Java文件。然后去 https://github.com/sendgrid/sendgrid-java/ BLOB /主/ pom.xml的。复制所有这两个的Java文件的依赖性,并在你的pom.xml文件粘贴。这将正常工作。

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.<init>(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.

这篇关于Sendgrid的Java不在Maven的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆