0

我是 JIRA 的新手,我下载了 eclipse Indigo 和 JIRA 5.0 版本的 m2e 插件

public class JIRAClient { 
       public static void main(String[] args) throws URISyntaxException {  
           final JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
           final URI jiraServerUri = new URI("http://jira.travelclick.net:8080/jira/rest/api"); 

Exception---> final JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "nsrivastava", "Password12");

           final NullProgressMonitor pm = new NullProgressMonitor();    
           final Issue issue = restClient.getIssueClient().getIssue("TST-1", pm);
           System.out.println(issue);          

           } 
       }

我有以下异常

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpConnectionManager
    at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory.create(JerseyJiraRestClientFactory.java:34)
    at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory.createWithBasicHttpAuthentication(JerseyJiraRestClientFactory.java:39)
    at client.JIRAClient.main(JIRAClient.java:24)

我还下载了 commons-logging-1.1.1.jar 文件,这是我的类路径文件(由 eclipse 创建

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="target/classes" path="src/main/java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" output="target/test-classes" path="src/test/java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="lib" path="C:/Users/bhaviksh/Downloads/httpcomponents-client-4.2.2-bin/httpcomponents-client-4.2.2/lib/commons-logging-1.1.1.jar"/>
    <classpathentry kind="output" path="target/classes"/>
</classpath>

这将是我的第一个程序,我什至不知道 JIRA 到底是什么。

4

1 回答 1

2

发生这种情况是因为您使用的 API 在运行时需要 Jakarta Commons 的HTTPClient。commons-httpclient 是否包含在您的运行时类路径中?(编译不需要它)

于 2012-10-30T05:56:48.233 回答