2013-02-23 57 views
2

我試圖建立一個簡單的javafx應用程序消費基於SOAP的web服務時,我正在閱讀java web服務:啓動並運行書(這個問題不是關於java web服務),我是使用: 部分 - NetBeans 7.3 - javafx-maven-plugin 1.5管理依賴(我使用maven 3.0.4) - tiwulfx 1.1來使用POJO如何從未使用maven構建的jar中將類從Maven依賴項中排除?

這裏是我的POM文件交互:

<groupId>org.tarrsalah</groupId> 
    <artifactId>teams-client</artifactId> 
    <version>0.0.99</version> 
    <packaging>jar</packaging> 

    <name>teams-client</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <netbeans.hint.license>apache20</netbeans.hint.license> 
    </properties> 

    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>commons-logging</groupId> 
     <artifactId>commons-logging</artifactId> 
     <version>1.1.1</version> 
     <scope>compile</scope> 
    </dependency 
    > 
    <dependency>  
     <groupId>org.apache.poi</groupId> 
     <artifactId>poi</artifactId> 
     <version>3.8</version> 
    </dependency> 

    <dependency> 
     <groupId>com.panemenu</groupId> 
     <artifactId>tiwulfx</artifactId> 
     <scope>compile</scope> 
     <version>1.1</version> 
     <type>jar</type>  
    </dependency> 

    <dependency> 
     <groupId>commons-beanutils</groupId> 
     <artifactId>commons-beanutils</artifactId> 
     <scope>compile</scope> 
     <version>1.8.3</version> 
    </dependency> 
    </dependencies>  

    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.jvnet.jax-ws-commons</groupId> 
     <artifactId>jaxws-maven-plugin</artifactId> 
     <version>2.2</version> 
     <executions> 
      <execution> 
      <goals> 
       <goal>wsimport</goal> 
      </goals> 
      <phase>generate-sources</phase> 
      </execution> 
     </executions> 
     <configuration>   
      <wsdlUrls> 
      <wsdlUrl>http://localhost:8080/teams?wsdl</wsdlUrl> 
      </wsdlUrls> 
      <packageName>org.tarrsalah.teams.client.generated</packageName>   > 
     </configuration> 
     </plugin>    

     <plugin> 
     <groupId>com.zenjava</groupId> 
     <artifactId>javafx-maven-plugin</artifactId> 
     <version> 1.5 </version> 
     <configuration>   
      <mainClass>org.tarrsalah.teams.client.app.App</mainClass> 
      <jarFileName>teams-client.jar</jarFileName> 
      <vendor>tarrsalah</vendor>               
     </configuration>          
     </plugin> 
    </plugins> 
    </build> 
</project> 

我下載了tiwulfx jar文件,並在POM文件中添加了所有依賴關係,並將其安裝在我的maven本地資源庫(該項目使用netbeans/ant簡單構建並僅提供一個jar文件)。

我試圖建立一個獨立的運行的JAR,當我運行: MVN全新的編譯JFX:建立-JAR

我得到這個編譯錯誤消息:

[INFO] Java home is: /home/tarrsalah/local/jdk1.7.0_15/jre 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 14.445s 
[INFO] Finished at: Sat Feb 23 23:39:31 CET 2013 
[INFO] Final Memory: 21M/350M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal com.zenjava:javafx-maven-plugin:1.5:build-jar (default-cli) on project teams-client: Invocation of JavaFX method 'packageAsJar' failed with an error. It's possible this plugin is not compatible with the version of JavaFX you are using. InvocationTargetException: Error: Failed to create jar file teams-client-0.0.99-jfx.jar: duplicate entry: com/javafx/main/Main.class -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

似乎該javafx類已包含在tiwulfx jar文件中,並與在打包階段由javafx-maven-plugin導入的JDK中的javafx類(我使用1.7u15)發生衝突。

這是樹相依的樣子:

[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building teams-client 0.0.99 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ teams-client --- 
[INFO] org.tarrsalah:teams-client:jar:0.0.99 
[INFO] +- junit:junit:jar:3.8.1:test 
[INFO] +- commons-logging:commons-logging:jar:1.1.1:compile 
[INFO] +- org.apache.poi:poi:jar:3.8:compile 
[INFO] | \- commons-codec:commons-codec:jar:1.5:compile 
[INFO] +- com.panemenu:tiwulfx:jar:1.1:compile 
[INFO] \- commons-beanutils:commons-beanutils:jar:1.8.3:compile 
[INFO] \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for duplicate) 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.137s 
[INFO] Finished at: Sun Feb 24 00:21:34 CET 2013 
[INFO] Final Memory: 10M/163M 
[INFO] ------------------------------------------------------------------------ 

我的問題是:我怎樣才能排除在tiwulfx的JavaFX類(包)在封裝階段?這可能是一個微不足道的問題,因爲我是maven生態系統的新手。

P.S:操作後生成的jar沒有任何問題,我只是試圖得到一個完美的生成結果。

回答

3

既然你需要手工的tiwulfx jar添加到您的Maven的回購協議(它不是由Maven的構建,它不是在一個Maven回購任何地方託管),你可能也只是用手先重新包裝。只需在zip編輯器中打開jar並刪除com/javafx文件夾即可。然後運行通常的install:install-file目標。

當爲jar選擇一個版本號時,最好添加一個額外的字符串以清楚它與原始網站的jar是否有點不同。

+0

感謝@artbristol,希望我們可以在下一個javafx 8中擺脫這種愚蠢的構建破解:) – tarrsalah 2013-02-24 00:01:24

+1

您可能還想聯繫panemu並要求他們不要將javafx代碼放入其可分發的jar包中 - 我不會首先看不出有什麼好的理由。 – jewelsea 2013-02-24 04:13:07

2

現在TiwulFX在Maven中可用。

<dependency> 
    <groupId>com.panemu</groupId> 
    <artifactId>tiwulfx</artifactId> 
    <version>1.1</version> 
</dependency> 

謝謝。

相關問題