我在java中使用Twilio SDK来解决java问题。我尝试使用2个不同版本的Twilio库,但我有两个不同的错误:
对于[twilio-java-sdk-6.3.0-jar-with-dependencies.jar],我收到了:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.impl.conn.DefaultClientConnectionOperator.<init>(Lorg/apache/http/conn/scheme/SchemeRegistry;Lorg/apache/http/conn/DnsResolver;)V
at org.apache.http.impl.conn.PoolingClientConnectionManager.createConnectionOperator(PoolingClientConnectionManager.java:140)
at org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:114)
at org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:99)
at org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:85)
at org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:93)
at com.twilio.sdk.TwilioClient.<init>(TwilioClient.java:151)
at com.twilio.sdk.TwilioRestClient.<init>(TwilioRestClient.java:23)
at com.twilio.sdk.TwilioRestClient.<init>(TwilioRestClient.java:19)
at iristk.app.bankAsst.Watson.sendMsg(Watson.java:82)
at iristk.app.bankAsst.Watson.main(Watson.java:100)
对于[twilio-7.9.1-jar-with-dependencies.jar],我收到了:
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.getDefaultRegistry(PoolingHttpClientConnectionManager.java:109)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:116)
at com.twilio.http.NetworkHttpClient.<init>(NetworkHttpClient.java:46)
at com.twilio.http.TwilioRestClient$Builder.build(TwilioRestClient.java:97)
at com.twilio.Twilio.getRestClient(Twilio.java:122)
at com.twilio.base.Creator.create(Creator.java:45)
at iristk.app.bankAsst.Watson.sendMsg(Watson.java:82)
at iristk.app.bankAsst.Watson.main(Watson.java:91)
2错误是什么意思?并且,如果可能的话,如何解决它们?
谢谢
答案 0 :(得分:0)
您的应用程序似乎有另一个版本的httpclient&amp; httpcore与wilio-java-sdk不兼容。请检查您的pom.xml并删除httpclient&amp; httpcore的依赖项。如果你在pom.xml中看不到httpclient&amp; httpcore的依赖关系,请运行“mvn dependency:tree”来查找包含httpclient&amp; httpcore的依赖项,然后添加排除节点以排除它们。
wilio-java-sdk-6.3.0-jar-with-dependencies.jar 包含 httpclient(4.2.6)和httpcore(4.2.5)
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.2.5</version>
</dependency>
twilio-7.9.1-jar-with-dependencies.jar 包含 httpclient(4.5.2)和httpcore(4.4.4)
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.4</version>
</dependency>