Я хочу подключиться к моему экземпляру jira в java через Rest-Api. Вот почему я реализую сначала подключение к хосту.Jira Rest Java Client
Я прочитал много учебников и нашел JRJC. Но ничего не сработало.
* Последнее обновление
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);
}
}
Я пытался импортировать следующие библиотеки: JIRA-отдых-Java-клиент-2.0.0-m2.jar, JIRA-отдых-Java-клиент-3.0.0.jar и jira-rest-java-client-4.0.0.jar
Но у меня есть еще одна проблема. Он не может найти Promise
Эта часть:
// 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();
Исключение составляет:
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)
ли кто-нибудь есть идея?
. . .
---------------- Обновлено - Попробуйте с Maven -------------------
- Я создал новый Maven - проект
- архетип: Maven-архетип-Quickstart 1,1
- GroupID и артефакта ID
Тогда у меня есть новый проект в затмении. Я скопировал свой старый код сверху в новый проект. Затем я скопировал зависимости от: https://github.com/eziztm/jira_rest_api_test/blob/master/pom.xml
Я не импортирую библиотеки, но он не регонирует какие-либо классы.
Мои Poem.xml сейчас:
<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>
Хорошо, я обновил содержание своего сообщения. Это правильный путь? – InfoEngi