【发布时间】:2022-12-15 15:45:55
【问题描述】:
我是 Maven 的新手,遇到了问题。我有一个 JavaFx 应用程序,但我一直在标题中收到错误消息。我尝试过许多不同版本的 POM,但无法正常工作。这是 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">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>Coursework2013</artifactId>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<javafx.version>19</javafx.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.9.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>Snake.GUI.Start</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>javazoom</groupId>
<artifactId>jlayer</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
</project>
和 Start 的开始(我猜这是相关的):
package Snake.GUI;
import Snake.GUI.controller.DataHandler;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import java.io.IOException;
public class Start extends Application {
我尝试了很多不同的方法来告诉它 main 在哪里等等,但没有用。我看过很多类似的问题,但他们的问题堆积如山,但他们的解决方案对我没有用。谢谢你的时间。
【问题讨论】:
-
我建议按照 mipa 的回答中的建议并按照他链接的文档使用 maven javafx 插件为您的分发创建一个 jlinked zip 文件。
-
无关:请坚持 java 命名约定(所有小写包名称)..并且不要将纯文本格式化为代码
标签: java maven javafx build pom.xml