JavaFx with Maven:找不到mainClass

时间:2017-08-01 07:46:39

标签: java eclipse maven javafx javafx-8

我有一个多模块maven项目,我遇到javaFx问题(我使用了插件zenJava)。

当我想构建jar时,我有这个错误: 无法执行目标com.zenjava:javafx-maven-plugin:8.8.3:项目XXXX上的build-jar(default-cli):目标com.zenjava的参数'mainClass':javafx-maven-plugin:8.8.3 :build-jar缺失或无效

但是,我在父pom中定义了mainClass。

这是父母:

    <dependencyManagement>
        <dependencies>
            <dependency>
               <groupId>commons-lang</groupId>
               <artifactId>commons-lang</artifactId>
                <version>2.6</version>
           </dependency>
       </dependencies>
  </dependencyManagement>
  <build>
    <pluginManagement>
        <plugins>
            <plugin>
                  <groupId>com.zenjava</groupId>
                  <artifactId>javafx-maven-plugin</artifactId>
                   <version>${javafx.version}</version>
                   <configuration>
                        <vendor>XXX</vendor>                
                        <mainClass>com.package.gui</mainClass>
                        <verbose>true</verbose>
                        <jarFileName>XXXX.jar</jarFileName>
                        <bundler>EXE</bundler>
                         <nativeInstallers/>
                    </configuration>
                    <executions>
                        <execution>
                            <id>create-jfxjar</id>
                            <phase>package</phase>
                            <goals>
                                <goal>build-jar</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>create-native</id>
                            <phase>package</phase>
                            <goals>
                                <goal>build-native</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.6.1</version>
                    <configuration>
                      <source>1.8</source>
                      <target>1.8</target>
                    </configuration>
            </plugin>
        </plugins>
    </build>

这是GUI模块的pom

 <build>
        <plugins>
            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
            </plugin>
        </plugins> 
    </build>

1 个答案:

答案 0 :(得分:1)

尝试将<pluginManagement>块从父pom移动到GUI pom并在GUI pom上运行build命令(这就是我为多模块JavaFX项目设置的方式,它没有问题)