如何在JIRA插件中包含JIRA REST Java Client?

Mla*_* B. 5 jira jira-plugin jira-rest-java-api

我是JIRA插件开发的新手,所以我的问题可能听起来太容易了,但请耐心一点,仔细阅读,因为我已经尝试了很多东西,在互联网上找到,而且没有一个能够工作.这就是我在这里问的原因,也是我最后的希望.

我想在我的JIRA插件中使用JIRA REST Java Client.直接的说明建议将以下内容添加到我的pom.xml中,一切都应该有效:

<dependency>
    <groupId>com.atlassian.jira</groupId>
    <artifactId>jira-rest-java-client</artifactId>
    <version>1.1-m02</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

但当然,它没有,因为在Eclipse中,一切都显示正常(没有任何错误/警告)之后atlas-mvn eclipse:eclipse,但是当我用atlas-run或运行JIRA时atlas-debug,一旦我尝试访问该行:

JerseyJiraRestClientFactory f = new JerseyJiraRestClientFactory();
Run Code Online (Sandbox Code Playgroud)

我得到了例外 java.lang.NoClassDefFoundError: com/atlassian/jira/rest/client/internal/jersey/JerseyJiraRestClientFactory

我再说一遍,在Eclipse中,一切都显示正常,没有一个警告/错误标记,但在运行时,我得到了异常.

我推荐的解决方案是将所有必需的依赖项添加到我的pom.xml中,但是由于有很多异常(如果需要将提供它们),我甚至无法正常启动JIRA.

那么,简单的问题是如何正确地做到这一点?更好的是,有没有人提供pom.xml文件+ src /文件夹的任何简单的WORKING示例,所以我可以弄清楚我在哪里错了?

非常感谢提前.

Mla*_* B. 4

正如jrjc-example-client 存储库中提到的,JRJC 的当前版本是 2.0,并且在提供的 pom.xml 文件中提到了一件重要的事情:

“JIRA 已经提供了 JRJC 所需的许多依赖项。我们需要将它们从 JRJC 依赖项中排除,因为我们不想将它们打包到插件中。”

因此,解决方案是从 JRJC 依赖项中排除这些内容:

<dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client</artifactId>
        <version>2.0.0-m2</version>
        <!--
        JIRA will already provide a number of dependencies that JRJC needs. We need to exclude them from the
        JRJC dependency as we don't want to package them up inside the plugin.
        -->
        <exclusions>
                <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>joda-time</groupId>
                        <artifactId>joda-time</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>com.sun.jersey</groupId>
                        <artifactId>jersey-json</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>com.google.guava</groupId>
                        <artifactId>guava</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>com.atlassian.sal</groupId>
                        <artifactId>sal-api</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>com.atlassian.event</groupId>
                        <artifactId>atlassian-event</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>commons-lang</groupId>
                        <artifactId>commons-lang</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>commons-codec</groupId>
                        <artifactId>commons-codec</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-context</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>com.sun.jersey</groupId>
                        <artifactId>jersey-core</artifactId>
                </exclusion>
        </exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)