1

我使用了 JIRA REST 客户端 api 并从 java 主程序运行它,

这是简单的代码,它尝试访问 JIRA 服务器(JIRA 6.1)

    public static void main (String args[]) {
        new Main().doIt();
    }

    public void doIt() {
        System.out.println("Start .. ");
        String url = "https://jira.com";
        String userName = "sdfsdfsdf";
        String password = "sdfsfsfsf";
        AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
        JiraRestClient client = factory.createWithBasicHttpAuthentication(URI.create(url), userName, password) ;
        System.out.println("JiraRestClient created successfully .. ");

    }

每次运行这个程序时,我都会得到“ClassNotFoundException”,在那里我找到依赖项并将 JAR 文件放在我的 LIB 文件夹中,

这样做时,我得到了奇怪的异常,这是 HTTPCLIENT 和 HTTPCLIENTCACHE jar 文件的结果。下面的屏幕截图显示了我的类路径中的 lib 文件

在此处输入图像描述

我得到的例外是

Start .. 
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.impl.client.cache.CacheConfig.setNeverCache1_0ResponsesWithQueryString(Z)V
    at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClient.<init>(DefaultHttpClient.java:155)
    at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:53)
    at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:35)
    at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:41)
    at com.arun.main.Main.doIt(Main.java:22)
    at com.arun.main.Main.main(Main.java:13)

有人可以建议我吗?

4

1 回答 1

2

找到具有此方法的正确 Jar 文件。jar文件可以从以下链接下载:

https://www.versioneye.com/java/org.apache.httpcomponents:httpclient-cache/4.2.1-atlassian-2

编辑 关于这个的小说明..即使你的 pom.xml 没有这个 jar 的条目..只需添加 -

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient-cache</artifactId>
    <version>4.2.1-atlassian-2</version>
</dependency>
于 2014-06-24T13:58:51.310 回答