我使用了 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)
有人可以建议我吗?