gpt4 book ai didi

Java - .jar 库方法冲突?

转载 作者:行者123 更新时间:2023-12-02 04:13:48 28 4
gpt4 key购买 nike

我有一个应用程序需要有 httpclient-4.2.5.jar 库才能正确运行。我还想使用 HtmlUnit 库(版本 2.12)。它失败(我认为)是因为库冲突(httpclient-4.2.5.jar 和 htmlunit-2.12.jar 之间)

这是我的日志的输出,但我不太明白它对我说的话,因为我没有在日志中调用任何这些方法...

Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException:   org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext()
at com.gargoylesoftware.htmlunit.HtmlUnitSSLSocketFactory.createSSLContext(HtmlUnitSSLSocketFactory.java:119)
at com.gargoylesoftware.htmlunit.HtmlUnitSSLSocketFactory.<init>(HtmlUnitSSLSocketFactory.java:102)
at com.gargoylesoftware.htmlunit.HtmlUnitSSLSocketFactory.buildSSLSocketFactory(HtmlUnitSSLSocketFactory.java:77)
at com.gargoylesoftware.htmlunit.HttpWebConnection.configureHttpsScheme(HttpWebConnection.java:608)
at com.gargoylesoftware.htmlunit.HttpWebConnection.createHttpClient(HttpWebConnection.java:555)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getHttpClient(HttpWebConnection.java:518)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:155)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1486)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1403)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:305)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:374)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:359)

最佳答案

这一切都非常简单。 HtmlUnit 通过反射在 HttpClient 代码中使用私有(private)方法:

http://sourceforge.net/p/htmlunit/code/8377/tree/trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HtmlUnitSSLSocketFactory.java#l113

相关方法已在 4.2.4 版本中删除。请参阅HTTPCLIENT-1320

关于Java - .jar 库方法冲突?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17497600/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com