我使用了 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 文件
我得到的异常(exception)是
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)
有人可以建议我吗?
最佳答案
找到具有此方法的正确 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>
关于java - JIRA6 REST API - HttpClient 和 HttpClientCache JAR 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24368303/