有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

线程“main”java中出现异常。lang.NoSuchFieldError:实例正在使用Unirest。post()

我正在使用Unirest。用于以下简单代码的post():

 HttpResponse<String> response = Unirest.post("http://localhost/web/webresources/...")
                    .header("content-type", "application/json")
                    .header("cache-control", "no-cache") 
                    .body("")
                    .asString();

我看到以下例外:

 Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
        at org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory.<init>(ManagedNHttpClientConnectionFactory.java:79)
        at org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory.<init>(ManagedNHttpClientConnectionFactory.java:83)
        at org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory.<clinit>(ManagedNHttpClientConnectionFactory.java:64)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingNHttpClientConnectionManager.java:522)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.<init>(PoolingNHttpClientConnectionManager.java:161)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.<init>(PoolingNHttpClientConnectionManager.java:145)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.<init>(PoolingNHttpClientConnectionManager.java:117)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.<init>(PoolingNHttpClientConnectionManager.java:111)
        at com.mashape.unirest.http.options.Options.refresh(Options.java:86)
        at com.mashape.unirest.http.options.Options.<clinit>(Options.java:46)
        at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:151)
        at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131)
        at `com.mashape.unirest.request.BaseRequest.asString(BaseRequest.java:56)`

共 (0) 个答案