2013-07-26 112 views
5

我是JIRA插件开发新手,所以我的问题可能听起来太简单了,但请耐心细致地阅读,因为我尝试了很多东西,发现在互联网上,而且都没有工作。这就是为什么我在这里问这是我最后的希望。如何将JIRA REST Java Client包含在JIRA插件中?

我想在我的JIRA插件中使用JIRA REST Java Client。直着instructions建议添加以下到我的pom.xml,一切都应该工作:

<dependency> 
    <groupId>com.atlassian.jira</groupId> 
    <artifactId>jira-rest-java-client</artifactId> 
    <version>1.1-m02</version> 
</dependency> 

但当然,这不,因为在Eclipse中,一切都显示正常(没有任何错误/警告) atlas-mvn eclipse:eclipse,但是当我运行JIRA与atlas-runatlas-debug,当我尝试访问该行:

JerseyJiraRestClientFactory f = new JerseyJiraRestClientFactory(); 

我得到的异常java.lang.NoClassDefFoundError: com/atlassian/jira/rest/client/internal/jersey/JerseyJiraRestClientFactory

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

推荐给我的解决方案是将all the needed dependencies添加到我的pom.xml中,但由于例外(如果需要,将提供它们),我甚至无法正常启动JIRA。

所以,简单的问题是如何正确地做到这一点?更妙的是,是否有人提供了pom.xml文件+ src /文件夹提供的任何简单的WORKING示例,以便我可以找出错误的位置?

非常感谢。

回答

3

正如jrjc-example-client repository 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> 
2

这可能不是直接回答你的问题,但可以给你在正确的方向上的一些线索。

JIRA使用双刃剑,即OSGI容器。在部署时在当地环境炸弹中进行开发时看起来很好。你可能有运气从OSGI的角度来追查事情。在那里,已经烧了几次。 HTH。

相关问题