使用 java rest API 在 jira 中创建问题

问题描述

我正在尝试使用 java rest-api 在 jira 中创建问题并收到此错误。卡在这里好久了。我已经提供了带有错误消息的 java 代码和我的 pom.xml 文件。 我曾尝试使用邮递员解决一些问题,并且成功了,并且还使用了 curl,但使用 java 我无法创建一个。 如果有人知道如何解决这个问题,请帮助...

import com.atlassian.jira.rest.client.api.AuthenticationHandler;
import com.atlassian.jira.rest.client.api.IssueRestClient;
import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.JiraRestClientFactory;
import com.atlassian.jira.rest.client.api.domain.BasicIssue;
import com.atlassian.jira.rest.client.api.domain.IssueFieldId;
import com.atlassian.jira.rest.client.api.domain.input.ComplexIssueInputFieldValue;
import com.atlassian.jira.rest.client.api.domain.input.FieldInput;
import com.atlassian.jira.rest.client.api.domain.input.IssueInput;
import com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder;
import com.atlassian.jira.rest.client.auth.BasicHttpAuthenticationHandler;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
import java.net.URI;

/**
 * Create a new JIRA Issue
 */
public class App {

    public static final String JIRA_URL = "https://id.atlassian.net/";
    public static final String JIRA_ADMIN_USERNAME = "username";
    public static final String JIRA_ADMIN_PASSWORD = "password";

    public static void main(String[] args) throws Exception {
        System.setProperty("javax.net.ssl.trustStore","C:/Users/himanshu/Documents/certs");

        URI jiraServerUri = new URI(JIRA_URL);

        AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();

        AuthenticationHandler auth = new BasicHttpAuthenticationHandler(JIRA_ADMIN_USERNAME,JIRA_ADMIN_PASSWORD);
        JiraRestClient restClient = factory.create(jiraServerUri,auth);
        IssueRestClient issueClient = restClient.getIssueClient();

        try {
            IssueInputBuilder iib = new IssueInputBuilder();
            iib.setProjectKey("TA");
            iib.setSummary("Created through JAVA");
            iib.setIssueTypeId(10004L);
            iib.setDescription("Testing Through JAVA");
            iib.setPriorityId(3L);

            IssueInput issue = iib.build();
            BasicIssue issueObj = issueClient.createIssue(issue).claim();

            System.out.println("Issue " + issueObj.getKey() + " created successfully");
        } finally {
            restClient.close();
        }

    }

}

pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.wip.main</groupId>
  <artifactId>JiraAPI</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <name>JiraAPI</name>
  <!-- FIXME change it to the project's website -->
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <dependencies>
    
      <!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-api -->
    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-api</artifactId>
        <version>7.1.0-QR20151030124437</version>
        <scope>provided</scope>
    </dependency> 
        
        <!-- https://mvnrepository.com/artifact/com.atlassian.util.concurrent/atlassian-util-concurrent -->
    <dependency>
        <groupId>com.atlassian.util.concurrent</groupId>
        <artifactId>atlassian-util-concurrent</artifactId>
        <version>3.0.0</version>
        <scope>provided</scope>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/com.atlassian.collectors/atlassian-collectors-util -->
<dependency>
    <groupId>com.atlassian.collectors</groupId>
    <artifactId>atlassian-collectors-util</artifactId>
    <version>1.1</version>
</dependency>
     <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.4</version>
        </dependency>
        
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <version>3.2.0-abbce37</version>
            <scope>provided</scope>
        </dependency>  
    
    <!-- new ones -->
    <dependency>
    <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.8.2</version>
     <scope>test</scope>
    </dependency> 
    
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-json</artifactId> 
     <version>1.5</version> 
     </dependency> 
     
     <dependency>
      <groupId>com.sun.jersey</groupId> 
      <artifactId>jersey-client</artifactId> 
      <version>1.9</version> 
      </dependency>
       
       <dependency> 
       <groupId>com.atlassian.jira</groupId> 
       <artifactId>jira-rest-java-client-api</artifactId> 
       <version>5.2.0</version> 
       </dependency> 
       
       <dependency> 
       <groupId>com.atlassian.jira</groupId> 
       <artifactId>jira-rest-java-client-core</artifactId> 
       <version>5.2.0</version> 
       </dependency>
        
        <dependency>
         <groupId>com.google.guava</groupId> 
         <artifactId>guava</artifactId> 
         <version>14.0-rc1</version> 
         </dependency>
          
          <dependency> 
          <groupId>org.codehaus.jettison</groupId>
           <artifactId>jettison</artifactId>
            <version>1.0.1</version>
             </dependency>
              
              <dependency> 
              <groupId>commons-io</groupId>
               <artifactId>commons-io</artifactId> 
               <version>2.4</version>
                </dependency> 
                
                <!-- https://mvnrepository.com/artifact/com.atlassian.plugins.rest/atlassian-rest-common -->
<dependency>
    <groupId>com.atlassian.plugins.rest</groupId>
    <artifactId>atlassian-rest-common</artifactId>
    <version>6.1.2</version>
    <scope>provided</scope>
</dependency>
                <!-- https://mvnrepository.com/artifact/com.atlassian.plugins/atlassian-plugins-core -->
<dependency>
    <groupId>com.atlassian.plugins</groupId>
    <artifactId>atlassian-plugins-core</artifactId>
    <version>5.4.0-01c481fbd</version>
</dependency>
                
  </dependencies>
   
   
  
  
   <repositories>
        <repository>
            <id>atlassian-public</id>
            <url>https://m2proxy.atlassian.com/repository/public</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>warn</checksumPolicy>
            </releases>
        </repository>
    </repositories>

<pluginRepositories>
    <pluginRepository>
        <id>atlassian-public</id>
        <url>https://m2proxy.atlassian.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
            <checksumPolicy>warn</checksumPolicy>
        </releases>
        <snapshots>
            <checksumPolicy>warn</checksumPolicy>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle,see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle,jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <!-- site lifecycle,see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

          

error

        log4j:WARN No appenders Could be found for logger                 
        (com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient$2).
        log4j:WARN Please initialize the log4j system properly.
        log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
        Exception in thread "main" java.lang.NoSuchMethodError:com.atlassian.jira.rest.client.api.IssueRestClient.createIssue(Lcom/atlassian/jira/rest/client/api/domain/input/IssueInput;)Lcom/atlassian/util/concurrent/Promise;
    at com.wip.main.JiraAPI.App.main(App.java:57)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...