相关疑难解决方法(0)

尝试使用API​​时出错.java.lang.NoSuchFieldError:INSTANCE

我正在尝试使用java程序连接到smartsheet api.最初我遇到了站点证书的问题,该证书通过将其添加到java密钥库来解决.现在,当我尝试运行我的代码时,我收到以下错误.

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 com.smartsheet.api.internal.http.DefaultHttpClient.<init>(DefaultHttpClient.java:64)
    at com.smartsheet.api.SmartsheetBuilder.build(SmartsheetBuilder.java:203)
    at SmartsheetConnection.main(SmartsheetConnection.java:13)
Run Code Online (Sandbox Code Playgroud)

这是我的代码(我按照他们的文档).

import com.smartsheet.api.*;
import com.smartsheet.api.models.*;
import com.smartsheet.api.models.enums.*;
import com.smartsheet.api.oauth.*;

public class SmartsheetConnection {
    public static void main(String[] args) throws SmartsheetException {
        // Set the access token.
        Token token = new Token();
        token.setAccessToken("foo");
        Smartsheet smartsheet = new SmartsheetBuilder().setAccessToken(token.getAccessToken()).build();
    }
}
Run Code Online (Sandbox Code Playgroud)

投掷错误的行是(第144行)

@Deprecated
    public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER
        = AllowAllHostnameVerifier.INSTANCE; 
Run Code Online (Sandbox Code Playgroud)

但我不知道该怎么做.我正在使用maven来获取依赖项.它与Apache HttpComponents的版本有关吗?

这是pom.xml

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target> …
Run Code Online (Sandbox Code Playgroud)

java-7 apache-httpcomponents smartsheet-api

9
推荐指数
2
解决办法
3万
查看次数