从Java服务连接JIRA

时间:2016-06-10 14:21:23

标签: java jira java-server jira-rest-java-api

我尝试使用JIRA REST Java Client从Java Service建立与JIRA的连接。我遵循以下教程:https://ecosystem.atlassian.net/wiki/display/JRJC/Tutorial

我正在尝试运行给定的示例Example1.java,但它给了我以下错误:

JerseyJiraRestClientFactory cannot be resolved to a type
JiraRestClient cannot be resolved to a type
NullProgressMonitor cannot be resolved to a type
Issue cannot be resolved to a type
FieldInput cannot be resolved to a type
TransitionInput cannot be resolved to a type

这是我的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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>gov.grantsolutions.pmo</groupId>
  <artifactId>jira-pmo</artifactId>
  <packaging>jar</packaging>
  <version>1.2</version>
  <name>jira-pmo</name>
  <url>http://maven.apache.org</url>
  <repositories>
      <repository>
          <id>atlassian.com</id>
          <name>Atlassian</name>
          <url>http://maven.atlassian.com/public</url>
          <layout>default</layout>
         </repository>
     <repository>
          <id>maven2-repository.dev.java.net</id>
          <name>Java.net Repository for Maven</name>
          <url>http://download.java.net/maven/2/</url>
          <layout>default</layout>
         </repository>
  </repositories>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2.1</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
          <archive>
            <manifest>
              <mainClass>gov.grantsolutions.pmo.App</mainClass>
            </manifest>
          </archive>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id> <!-- this is used for inheritance merges -->
            <phase>package</phase> <!-- bind to the packaging phase -->
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
        <dependency>
      <groupId>com.atlassian.jira</groupId>
      <artifactId>jira-rest-java-client</artifactId>
      <version>0.2</version>
    </dependency>
       <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
      <version>1.6.2</version>
      </dependency>
      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>r08</version>
      </dependency>
      <dependency>
      <groupId>org.bluestemsoftware.open.maven.tparty</groupId>
      <artifactId>jettison</artifactId>
      <version>1.1</version>
      </dependency>
      <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.3</version>
      </dependency>
      <dependency>
      <groupId>commons-httpclient</groupId>
      <artifactId>commons-httpclient</artifactId>
      <version>3.1</version>
      </dependency>
      <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.0.4</version>
      </dependency>
      <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.19</version>
      </dependency>
      <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-core</artifactId>
        <version>1.17.1</version>
      </dependency>
      <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.19</version>
      </dependency>
      <dependency>
      <groupId>com.sun.jersey.contribs</groupId>
      <artifactId>jersey-apache-client</artifactId>
      <version>1.19</version>
      </dependency>
      <dependency>
          <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-impl</artifactId>
      <version>2.1.12</version>
      </dependency>
      <dependency>
      <groupId>javax.activation</groupId>
      <artifactId>activation</artifactId>
      <version>1.1</version>
      </dependency>
      <dependency>
      <groupId>javax.ws.rs</groupId>
      <artifactId>jsr311-api</artifactId>
      <version>1.1.1</version>
      </dependency>
      <dependency>
      <groupId>javax.xml</groupId>
      <artifactId>jaxb-api</artifactId>
      <version>2.1</version>
      </dependency>
      <dependency>
    <groupId>javax.xml.stream</groupId>
    <artifactId>stax-api</artifactId>
    <version>1.0-2</version>
      </dependency>
      <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-core-asl</artifactId>
      <version>1.1.1</version>
      </dependency>
      <dependency>
      <groupId>stax</groupId>
      <artifactId>stax-api</artifactId>
      <version>1.0.1</version>
      </dependency>      
  </dependencies>
</project>

请告诉我还要添加什么来摆脱这些错误。

1 个答案:

答案 0 :(得分:0)

&#34;无法解析为某种类型&#34;通常闻起来像你的项目没有正确建立。因此,maven尚未下载正确的库,您的IDE无法识别这些类。

通常是

mvn clean package

应该这样做。

然而,生态系统.atlassian.net上的教程已经过时了,特别是在pom依赖性方面。

您可以在此处查看我编写的一些示例代码,以使用JRJC访问Jira Rest API:https://github.com/somaiah/jrjc

下载我的代码后,请更改网址,用户名,密码和问题ID编号,代码应该有效。