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