我正在尝试使用 Digital Ocean java 库,并在尝试创建与以下内容的连接时:
CloseableHttpClient httpClient = HttpClients.createDefault();
client = new DigitalOceanClient("v2", token, httpClient);
问题在于CloseableHttpClient httpClient
对象。该库使用 httpcore 4.4.1 版和 httpclient 4.5 版。它给了我一个 java.lang.NoSuchFieldError。
这是我的日志:
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:955)
at org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58)
at main.java.servers.DigitalOceanServer.setup(DigitalOceanServer.java:28)
我发现关于 NoSuchFieldError 的信息和文档很少,所以我假设它与导致此错误的 httpcore 和/或 httpclient 的版本有关。