Javafx项目不能用maven编译 [英] Javafx project doesn't compile with maven

查看:229
本文介绍了Javafx项目不能用maven编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java FX项目,正在使用maven 3.0.5构建。当我运行mvn package / install时,项目失败并抱怨包javafx。 * 不存在。根据我的理解,Javafx打包在Java 1.7中,因此构建不会选择它是没有意义的。当我在我的IDE(intellij)中编译它时它工作正常,之后我的maven构建也成功安装,但是我不希望每次我进行干净安装时都要通过IDE。任何想法?

I have a Java FX project and am using maven 3.0.5 to build. When i run mvn package/install, the project fails and complains that the package javafx.* doesn't exist. Javafx is packaged in Java 1.7 to my understanding so it doesn't make sense that the build does not pick this up. When i compile it within my IDE (intellij) it works fine and after that my maven build also successfully installs, however i do not wish to have to go through the IDE every time i do a clean install. any ideas?

这是我的pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>thenaglecode</artifactId>
        <groupId>com.thenaglecode</groupId>
        <version>1.0.0.Pre-Alpha</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>system-setup</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-vfs2</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <includeEmptyDirs>true</includeEmptyDirs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.akathist.maven.plugins.launch4j</groupId>
                <artifactId>launch4j-maven-plugin</artifactId>
                <version>1.5.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>launch4j</goal>
                        </goals>
                        <configuration>
                            <headerType>gui</headerType>
                            <jre>
                                <path>C:\Program Files\Java\jre7</path>
                                <minVersion>1.7.0</minVersion>
                                <initialHeapSize>128</initialHeapSize>
                                <maxHeapSize>1024</maxHeapSize>
                            </jre>
                            <jar>${project.build.directory}/${project.build.finalName}.jar</jar>
                            <outfile>${project.build.directory}/systemsetup.exe</outfile>
                            <classPath>
                                <mainClass>com.thenaglecode.Start</mainClass>
                            </classPath>
                            <singleInstance>
                                <mutexName>thenaglecode-system-setup</mutexName>
                            </singleInstance>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

这是我的日志:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/CommandHelper.java:[3,26] package javafx.application does not exist
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/ListAndOptionsController.java:[3,26] package javafx.beans.value does not exist
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/ListAndOptionsController.java:[4,26] package javafx.beans.value does not exist
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/ListAndOptionsController.java:[5,26] package javafx.collections does not exist
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/ListAndOptionsController.java:[6,20] package javafx.event does not exist
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/ListAndOptionsController.java:[7,20] package javafx.event does not exist
...
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/Context.java:[3,28] package javafx.scene.control does not exist
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/ServiceMuncher.java:[3,31] package com.sun.istack.internal does not exist
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/TypeInfo.java:[3,31] package com.sun.istack.internal does not exist
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/NumericOnlyTextFieldChangeListener.java:[3,31] package com.sun.istack.internal does not exist
[ERROR] /C:/Users/Macindows/IdeaProjects/thenaglecode/system-setup/src/main/java/com/thenaglecode/NumericOnlyTextFieldChangeListener.java:[4,26] package javafx.beans.value does not exist
[ERROR] -> [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/MojoFailureException

Process finished with exit code 1

感谢您的帮助。

推荐答案

将其置于依赖项中(取决于您的jdk所在的位置)将有助于编译依赖项但是你应该用一个用户可以在settings.xml或maven系统属性中指定的变量替换它:

placing this in the dependencies (depending on where your jdk is) will help the dependency compile, however you should probably replace it with a variable that the user can specify in their settings.xml or maven system properties:

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>javaFX</artifactId>
        <version>2.2</version>
        <scope>system</scope>
        <systemPath>C:\Program Files\Java\jre7\lib\jfxrt.jar</systemPath>
    </dependency>

参见使用JavaFX的Maven项目(在`lib`中使用jar文件),了解更多有关原因的详细信息

see Maven project with JavaFX (with jar file in `lib`) for more details as to why

这篇关于Javafx项目不能用maven编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆