2013-07-26 35 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。

相關問題