2017-01-30 3 views
-1

Я пытаюсь подключиться к JIRA и создать проблему. Я написал тот же код, но у меня есть проблема.найти проблему от JIRA с помощью java

pom.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.fis.poc</groupId> 
      <artifactId>JIRATEST1</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
      <packaging>jar</packaging> 

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

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

      <dependencies> 
      <!-- https://mvnrepository.com/artifact/com.atlassian.sal/sal-api --> 
     <!-- https://mvnrepository.com/artifact/com.atlassian.sal/sal-api --> 
     <!-- <dependency> 
      <groupId>com.atlassian.sal</groupId> 
      <artifactId>sal-api</artifactId> 
      <version>2.10.0</version> 
     </dependency> --> 

     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpclient-cache</artifactId> 
      <version>4.2.1-atlassian-2</version> 
     </dependency> 


     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpclient-cache</artifactId> 
      <version>4.2</version> 
     </dependency> 

     <dependency> 
      <groupId>org.json</groupId> 
      <artifactId>json</artifactId> 
      <version>20160810</version> 
     </dependency> 



     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpclient</artifactId> 
      <version>4.5.2</version> 
     </dependency> 


     <dependency> 
      <groupId>com.atlassian.sal</groupId> 
      <artifactId>sal-api</artifactId> 
      <version>2.7.1</version> 
     </dependency> 

     <dependency> 
      <groupId>com.atlassian.httpclient</groupId> 
      <artifactId>atlassian-httpclient-spi</artifactId> 
      <version>0.17.0-m01</version> 
     </dependency> 



     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpcore-nio</artifactId> 
      <version>4.0-alpha6</version> 
     </dependency> 



     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpasyncclient</artifactId> 
      <version>4.1.2</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-beans</artifactId> 
      <version>4.1.9.RELEASE</version> 
     </dependency> 

     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpcore-nio</artifactId> 
      <version>4.4.5</version> 
     </dependency> 



     <dependency> 
      <groupId>com.atlassian.httpclient</groupId> 
      <artifactId>atlassian-httpclient-apache-httpcomponents</artifactId> 
      <version>0.11.0</version> 
     </dependency> 



     <dependency> 
      <groupId>com.atlassian.httpclient</groupId> 
      <artifactId>atlassian-httpclient-api</artifactId> 
      <version>0.23.2</version> 
     </dependency> 


     <dependency> 
      <groupId>com.atlassian.event</groupId> 
      <artifactId>atlassian-event</artifactId> 
      <version>2.2.0</version> 
     </dependency> 


     <dependency> 
      <groupId>com.atlassian.util.concurrent</groupId> 
      <artifactId>atlassian-util-concurrent</artifactId> 
      <version>3.0.0</version> 
     </dependency> 

      <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-core</artifactId> 
       <version>3.0.0</version> 
      </dependency> 

      <dependency> 
       <groupId>com.atlassian.jira</groupId> 
       <artifactId>jira-rest-java-client-api</artifactId> 
       <version>4.0.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>org.slf4j</groupId> 
       <artifactId>slf4j-simple</artifactId> 
       <version>1.6.4</version> 
      </dependency> 
      <dependency> 
       <groupId>commons-io</groupId> 
       <artifactId>commons-io</artifactId> 
       <version>2.4</version> 
      </dependency> 
     </dependencies> 


     </project> 

И я пишу Java-код для извлечения информации о какой-то проблеме. Который уже создан в JIRA. Я поставил статические переменные для URI, имени пользователя и пароля.

public static void main(String[] args) throws Exception { 
     Issue issue = getIssue("TEST_12332"); 
    } 

    public static Issue getIssue(String issueKey) throws Exception{ 
      final URI jiraServerUri = new URI(JIRA_URL); 
      final JiraRestClient restClient = new AsynchronousJiraRestClientFactory().createWithBasicHttpAuthentication(jiraServerUri, JIRA_ADMIN_USERNAME, JIRA_ADMIN_PASSWORD); 
      Promise issuePromise = restClient.getIssueClient().getIssue(issueKey); 
      return (Issue)issuePromise.claim(); 
      // return Optional.ofNullable((Issue) issuePromise.claim()).orElseThrow(() -> new Exception("No such issue")); 
    } 

Но я получил сообщение об ошибке:

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:42) 
    at com.fis.poc.JIRATEST1.JiraTest.getIssue(JiraTest.java:37) 
    at com.fis.poc.JIRATEST1.JiraTest.main(JiraTest.java:28) 
+0

Вам это поможет? http://stackoverflow.com/questions/18249767/apache-client-cache-jar –

ответ

0

Теперь его работает отлично, моя ошиблась мне нужно, чтобы добавить https://m2proxy.atlassian.com/repository/public репозиторий в моей pom.I вещей Из-за отсутствие хранилища некорректной баночки была downloaded.Now my pom is

<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.fis.poc</groupId> 
    <artifactId>jiraClientApp1</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

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

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

    <dependencies> 
     <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>3.0.0</version> 
     </dependency> 
     <dependency> 
      <groupId>com.atlassian.jira</groupId> 
      <artifactId>jira-rest-java-client-core</artifactId> 
      <version>3.0.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>org.slf4j</groupId> 
      <artifactId>slf4j-simple</artifactId> 
      <version>1.6.4</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-io</groupId> 
      <artifactId>commons-io</artifactId> 
      <version>2.4</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> 


</project> 
Смежные вопросы