2

我正在尝试构建一个简单的javafx应用程序以在阅读 java web 服务时使用基于 SOAP 的 web服务:启动和运行书(问题不是关于 java web 服务),我正在使用:-netbeans 7.3- javafx-maven-plugin 1.5用于管理依赖项(我正在使用maven 3.0.4) - tiwulfx 1.1与 POJO 交互

这是我的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 clean compile jfx:build-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(我使用的是 1.7u15)中的 javafx 类发生冲突。

这就是树依赖项的样子:

[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 生态系统的新手。

PS:运行后生成的jar没有任何问题,我只是想得到一个完美的构建结果。

4

2 回答 2

3

由于您需要tiwulfx手动将 jar 添加到您的 Maven 存储库中(它不是由 Maven 构建的,也不是托管在任何地方的 Maven 存储库中),您不妨先手动重新打包它。只需在 zip 编辑器中打开 jar 并删除该com/javafx文件夹。然后运行通常的install:install-file目标。

为 jar 选择版本号时,最好添加一个额外的字符串,以表明它与原始网站中的 jar 略有不同。

于 2013-02-23T23:44:25.377 回答
2

现在 TiwulFX 在 Maven 中可用。

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

谢谢。

于 2013-03-19T04:27:13.580 回答