JavaFx Maven配置推荐(七)
JavaFx Maven配置推荐(七)
JavaFX 从入门到入土系列
开发Java Fx,推荐使用Maven管理项目,下面是常用到的配置基于jdk11+
<!-- 打成 jar 包 -->
<packaging>jar</packaging>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<javafx.version>11</javafx.version>
<!-- Maven 打包编码 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<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>
</dependencies>
<build>
<plugins>
<!-- javafx 插件 可以通过 mvn clean javafx:run 运行指定的 main -->
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.5</version>
<configuration>
<mainClass>
top.lingkang.potato.PotatoApplication
</mainClass>
</configuration>
</plugin>
<!--Maven 打jar包插件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<addClasspath>true</addClasspath>
<useUniqueVersions>false</useUniqueVersions>
<!--打包时,将 resources/lib 下的依赖引入-->
<classpathPrefix>lib/</classpathPrefix>
<!--指向main函数-->
<mainClass>top.lingkang.potato.PotatoApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>