Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Maven编译具有所有依赖项的JavaFXJAR_Java_Maven_Javafx - Fatal编程技术网

使用Maven编译具有所有依赖项的JavaFXJAR

使用Maven编译具有所有依赖项的JavaFXJAR,java,maven,javafx,Java,Maven,Javafx,Java和Maven新手 我正在尝试配置我的应用程序,以便通过cmd行生成一个jar,其中包含了我的所有依赖项 据我所知,我正在正确设置Pom以使用此插件: 以下是我在Pom中的依赖项: <dependencies> <dependency> <groupId>se.michaelthelin.spotify</groupId> <artifactId>spotif

Java和Maven新手

我正在尝试配置我的应用程序,以便通过cmd行生成一个jar,其中包含了我的所有依赖项

据我所知,我正在正确设置Pom以使用此插件:

以下是我在Pom中的依赖项:

    <dependencies>
        <dependency>
            <groupId>se.michaelthelin.spotify</groupId>
            <artifactId>spotify-web-api-java</artifactId>
            <version>2.1.1</version>
        </dependency>

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11</version>
        </dependency>
    </dependencies>
处理此问题的另一个SO主题是像这样配置
maven assembly plugin
(据我所知,这就是打包所有依赖项的内容):

maven汇编插件
创建可执行文件
包裹
单一的
${test.pack.dir}
假的
带有依赖项的jar
推荐
使用这个Maven配置,我运行以下命令来编译.jar:
mvn clean compile jfx:build jar

但是,除了存放
MANIFEST.MF
META-INF
文件夹之外,编译到我的
target
目录的.jar是完全空的

我到底做错了什么?Maven给了我以下日志消息
[INFO]将'deploy'目录添加到Mojo类路径:/Users/adonis/school/recommendify/src/main/deploy
。什么是魔咒?我应该使用
deploy
包来存放我的.java文件吗?早些时候,我遇到了一个问题,在使用Intellij的run应用程序功能时,我的fxml
视图
包没有被编译到classes output目录,经过一点研究,我推断我的fxml应该存储在
资源/fxml
下,而不是我恰当命名的
视图
。这让我相信我需要一个“部署”目录/包


非常感谢您的帮助:)

尝试使用Maven Jar插件。这就是我在所有JavaFX项目中所做的:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.1.0</version>
    <configuration>
        <archive>
            <manifest>
                <mainClass>Your.Main.Class.Here</mainClass>
            </manifest>
        </archive>
    </configuration>
</plugin>

org.apache.maven.plugins
maven jar插件
3.1.0
你的主课在这里

那么我就不会使用
mvnjfx:buildjar
来编译了,对吗?什么命令<代码>mvn清洁包?
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
            <execution>
                <id>create-executable</id>
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <outputDirectory>${test.pack.dir}</outputDirectory>
            <appendAssemblyId>false</appendAssemblyId>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
            <archive>
                <manifest>
                    <mainClass>recommendify.Main</mainClass>
                </manifest>
            </archive>
        </configuration>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.1.0</version>
    <configuration>
        <archive>
            <manifest>
                <mainClass>Your.Main.Class.Here</mainClass>
            </manifest>
        </archive>
    </configuration>
</plugin>