且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Maven项目在JavaFX中生成可执行jar

更新时间:2022-02-15 18:02:04

Maven阴影插件通过以下配置为我工作:

Maven shade plugin worked for me with this configuration:

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>Main</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

只需将 Main 替换为您的主类.
要创建胖子罐,您需要调用maven package命令:

Just replace Main with your main class.
To create the fat jar you need to call maven package command:

mvn package