我可以使用其余客户端 API 创建 jira 问题,但我无法将 screeshot/附件附加到现有JIRA
问题。如果有人能提供一个非常感谢的解决方案,那将非常有帮助。
我刚刚编写了以下代码片段,用于将 jpeg 文件附加到现有的JIRA Issue
. 但后来我遇到了“线程“主”中的异常java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpConnectionManager"
代码片段:-
私有静态字符串 addAttachment(字符串附件文件路径)抛出 URISyntaxException,FileNotFoundException{
final java.net.URI jiraServerUri = new java.net.URI("https://oliveits.atlassian.net");
FileInputStream fileStreamPath = new FileInputStream(attachmentfilenamepath);
JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
NullProgressMonitor pm = new NullProgressMonitor();
System.out.println("Server Url :"+jiraServerUri);
JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri,"mobileqa","MobileQA1234");
Issue issue1 = restClient.getIssueClient().getIssue(newKey, pm);
final java.net.URI AttachmentUri = new java.net.URI(jiraServerUri+"/rest/api/2/issue/"+newKey+"/attachments");
System.out.println("URI :"+issue1.getAttachmentsUri());
//restClient.getIssueClient().addAttachment(pm,issue1.getAttachmentsUri(), fileStreamPath , imageName);
restClient.getIssueClient().addAttachment(pm, AttachmentUri, fileStreamPath, imageName);
return attachmentfilepath;
}
例外:-
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpConnectionManager
at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory.create(JerseyJiraRestClientFactory.java:34)
at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory.createWithBasicHttpAuthentication(JerseyJiraRestClientFactory.java:39)
at com.jtricks.JTricksRESTClient.addAttachment(JTricksRESTClient.java:157)
at com.jtricks.JTricksRESTClient.main(JTricksRESTClient.java:101)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpConnectionManager
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
刚刚将丢失的 jar 文件添加到类路径中。但我得到了一个例外,如下所述。
异常 Msg-1:com.sun.jersey.api.client.ClientHandlerException:Java 类 com.sun.jersey.multipart.MultiPart 和 Java 类型类 com.sun.jersey.multipart.MultiPart 和 MIME 的消息体编写器媒体类型多部分/表单数据;边界=边界_1_18541827_1358346116249 未找到
异常消息 2:com.sun.jersey.api.client.ClientHandlerException:Java 类 com.sun.jersey.multipart.MultiPart 和 Java 类型类 com.sun.jersey.multipart.MultiPart 和 MIME 的消息体编写器媒体类型多部分/表单数据;边界=边界_1_18541827_1358346116249 未找到