Sendgrid Java不在Maven中工作

我在我的应用程序中使用https://github.com/sendgrid/sendgrid-java 。 当我尝试运行sendgridexample.java时,它会导致错误InvocationTargetException,并且根本原因是

java.lang.NoClassDefFoundError: org/apache/http/impl/client/HttpClientBuilder com.sendgrid.SendGrid.(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); } 

是的,我找到了解决方案。 转到https://github.com/sendgrid/sendgrid-java/tree/master/src/main/java/com/sendgrid 。 复制两个java文件[SendGrid.java和SendGridException.java]并在应用程序中创建一个com.sendgrid文件夹,并将这两个java文件粘贴到该文件夹​​中。 然后转到https://github.com/sendgrid/sendgrid-java/blob/master/pom.xml 。 复制这两个java文件的所有依赖项并粘贴到您的pom.xml文件中。 它会工作正常。