2017-02-22 8 views
2

Ich möchte eine Verbindung zu meiner Jira-Instanz in Java über Rest-Api herstellen. Deshalb implementiere ich zuerst die Verbindung zum Host.Jira Rest Java Client

Ich lese viele Tutorials und ich fand JRJC. Aber nichts hat funktioniert.

* aktualisiert

package com.jira.main; 

    import java.net.URI; 
    import java.net.URISyntaxException; 

    import com.atlassian.jira.rest.client.JiraRestClient; 
    import com.atlassian.jira.rest.client.JiraRestClientFactory; 
    import com.atlassian.jira.rest.client.domain.Issue; 
    import com.atlassian.jira.rest.client.domain.User; 
    import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory; 
    import com.atlassian.util.concurrent.Promise; 



public class App 
{ 

    private static URI uri = URI.create("http://localhost:8080/jira"); 

    public static void main(String[] args) throws URISyntaxException 
    { 

     // Construct the JRJC client 
     System.out.println(String.format("Logging in to %s with username '%s' and password '%s'", "http://localhost:8080/", "bwanke", "Jako2014W!")); 
     final AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory(); 
     final com.atlassian.jira.rest.client.api.JiraRestClient client = factory.createWithBasicHttpAuthentication(uri, "bwanke", "Jako2014!"); 


     // Invoke the JRJC Client 
     Promise<com.atlassian.jira.rest.client.api.domain.User> promise = client.getUserClient().getUser("bwanke"); 
     com.atlassian.jira.rest.client.api.domain.User user = promise.claim(); 


     Promise<com.atlassian.jira.rest.client.api.domain.Issue> promiseIssue = client.getIssueClient().getIssue("TEST-1"); 
     com.atlassian.jira.rest.client.api.domain.Issue issue = promiseIssue.claim(); 

     // Print the result 
     System.out.println(String.format("Your admin user's email address is: %s\r\n", user.getEmailAddress())); 

     // Print the result 
     System.out.println("some TEST-1 details " + issue.getAssignee() + " " + issue.getSummary() + " " + issue.getWorklogs()); 
     // Done 
     System.out.println("Example complete. Now exiting."); 
     System.exit(0); 




    } 
} 

Ich habe versucht, die folgenden Bibliotheken zu importieren: jira-rest-java-client-2.0.0-m2.jar, jira-rest-java-client-3.0.0.jar und jira-rest-java-client-4.0.0.jar

Aber ich habe immer noch ein Problem. Er kann nicht finden Versprechen

Dieser Teil:

// Invoke the JRJC Client 
Promise<User> promise = client.getUserClient().getUser("ezizconduct"); 
User user = promise.claim(); 


Promise<Issue> promiseIssue = client.getIssueClient().getIssue("TEST-1"); 
Issue issue = promiseIssue.claim(); 

Die Ausnahme ist:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    Promise cannot be resolved to a type 
    The type com.atlassian.util.concurrent.Promise cannot be resolved. It is indirectly referenced from required .class files 
    The method getUser(String) from the type UserRestClient refers to the missing type Promise 
    Promise cannot be resolved to a type 
    The method getIssue(String) from the type IssueRestClient refers to the missing type Promise 

    at com.jira.main.main(main.java:23) 

Hat jemand eine Idee?

. . .

---------------- aktualisiert - mit Maven Versuchen -------------------

  • ich habe eine neue maven - Projekt
  • Urform: maven-Urbild-quickstart 1.1
  • GroupId und Artifact ID

Dann habe ich ein neues Projekt in eclipse. Ich habe meinen alten Code von oben auf das neue Projekt kopiert. Dann habe ich die Abhängigkeiten kopiert von: https://github.com/eziztm/jira_rest_api_test/blob/master/pom.xml

Ich importiere keine Bibliotheken, aber er registriert keine Klassen.

Mein Poem.xml ist jetzt:

<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.jira</groupId> 
    <artifactId>main</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>main</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 

     <dependency> 
      <groupId>com.atlassian.fugue</groupId> 
      <artifactId>fugue</artifactId> 
      <version>2.6.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-simple</artifactId> 
      <version>1.6.4</version> 
     </dependency> 
     <dependency> 
      <groupId>com.atlassian.jira</groupId> 
      <artifactId>jira-rest-java-client-api</artifactId> 
      <version>4.0.0</version> 
      <exclusions> 
       <exclusion> 
        <groupId>stax</groupId> 
        <artifactId>stax-api</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <!-- JRJC is distributed under the Apache 2.0 license. --> 
      <groupId>com.atlassian.jira</groupId> 
      <artifactId>jira-rest-java-client-core</artifactId> 
      <version>4.0.0</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> 


</project> 

Antwort

2

Der Typ com.atlassian.util.concurrent.Promise nicht aufgelöst werden kann. Es wird indirekt von erforderlichen .class-Dateien referenziert.

Sie müssen eine transitive Abhängigkeit von com.atlassian.util.concurrent.Promise bereitstellen, die zur Laufzeit benötigt wird. Fügen Sie die folgende Abhängigkeit zu Ihrem POM hinzu, um das gemeldete Problem zu beheben.

<dependency> 
<groupId>com.atlassian.util.concurrent</groupId> 
<artifactId>atlassian-util-concurrent</artifactId> 
<version>2.6.2</version> 
</dependency> 
+0

Okay, ich habe den Inhalt meines Beitrags aktualisiert. Ist das der richtige Weg? – InfoEngi