JavaFx应用打包

1JavaFx应用打包

1.1 为不支持模块管理的包进行模块信息注入

当报错或警告自动模块,请不要将此库上传到公共仓库时使用

1.1.1生成jar包的module-info.java文件

首先cd当jar包所在目录,然后执行以下指令(jars是关键)

jdeps --ignore-missing-deps --generate-module-info jars [jar包名]

执行后会在当前目录生成jar文件夹,里面就是module-info.java文件

1.1.2 注入module-info.java文件并生成新的jar包

使用moditect插件可以方便的将一个包,变成一个模块

首先点击maven插件-- javafx-- javafx:jlink,查看哪些包不支持模块化然后针对那些包执行 《1.1.1》
配置好moditect,点击maven插件-- javafx-- javafx:jlink,即可在target下生成modules目录,里面就是已经注入模块信息的新jar包,使用新jar替换掉本地maven仓库的jar包

反复执行此过程,直到jlink成功,此时target下会生成app.zip压缩包,解压,打开bin,双击app.bat,就可以启动你的项目了

<plugin>  
    <groupId>org.moditect</groupId>  
    <artifactId>moditect-maven-plugin</artifactId>  
    <version>1.0.0.RC2</version>  
    <executions>  
        <execution>  
            <id>add-module-infos</id>  
            <phase>generate-resources</phase>  
            <goals>  
                <goal>add-module-info</goal>  
            </goals>  
            <configuration>  
                <outputDirectory>${project.build.directory}/modules</outputDirectory>  
                <!--覆盖重复文件,防止报错-->  
                <overwriteExistingFiles>true</overwriteExistingFiles>  
                <modules>  
  
                    <!--commons-digester-->  
                    <module>  
                        <artifact>  
                            <groupId>commons-digester</groupId>  
                            <artifactId>commons-digester</artifactId>  
                            <version>2.1</version>  
                        </artifact>  
  
                        <moduleInfoSource>  
                            module commons.digester {  
                            requires java.desktop;  
  
                            requires transitive java.xml;  
  
                            exports org.apache.commons.digester;  
                            exports org.apache.commons.digester.annotations;  
                            exports org.apache.commons.digester.annotations.handlers;  
                            exports org.apache.commons.digester.annotations.internal;  
                            exports org.apache.commons.digester.annotations.providers;  
                            exports org.apache.commons.digester.annotations.reflect;  
                            exports org.apache.commons.digester.annotations.rules;  
                            exports org.apache.commons.digester.annotations.spi;  
                            exports org.apache.commons.digester.annotations.utils;  
                            exports org.apache.commons.digester.parser;  
                            exports org.apache.commons.digester.plugins;  
                            exports org.apache.commons.digester.plugins.strategies;  
                            exports org.apache.commons.digester.substitution;  
                            exports org.apache.commons.digester.xmlrules;  
  
                            }  
                        </moduleInfoSource>  
                    </module>  
  
                    <!--commons-lang3-->  
                    <module>  
                        <artifact>  
                            <groupId>org.apache.commons</groupId>  
                            <artifactId>commons-lang3</artifactId>  
                            <version>3.13.0</version>  
                        </artifact>  
                        <moduleInfoSource>  
                            module org.apache.commons.lang3 {  
                                requires transitive java.desktop;  
  
                                exports org.apache.commons.lang3;  
                                exports org.apache.commons.lang3.arch;  
                                exports org.apache.commons.lang3.builder;  
                                exports org.apache.commons.lang3.compare;  
                                exports org.apache.commons.lang3.concurrent;  
                                exports org.apache.commons.lang3.concurrent.locks;  
                                exports org.apache.commons.lang3.event;  
                                exports org.apache.commons.lang3.exception;  
                                exports org.apache.commons.lang3.function;  
                                exports org.apache.commons.lang3.math;  
                                exports org.apache.commons.lang3.mutable;  
                                exports org.apache.commons.lang3.reflect;  
                                exports org.apache.commons.lang3.stream;  
                                exports org.apache.commons.lang3.text;  
                                exports org.apache.commons.lang3.text.translate;  
                                exports org.apache.commons.lang3.time;  
                                exports org.apache.commons.lang3.tuple;  
                                exports org.apache.commons.lang3.util;  
  
                            }  
  
                        </moduleInfoSource>  
                    </module>  
  
                    <!--javax.inject-->  
                    <module>  
                        <artifact>  
                            <groupId>javax.inject</groupId>  
                            <artifactId>javax.inject</artifactId>  
                            <version>1</version>  
                        </artifact>  
                        <moduleInfoSource>  
                            module javax.inject {  
                                exports javax.inject;  
                            }  
                        </moduleInfoSource>  
                    </module>  
  
                    <!--commons-collections-->  
                    <module>  
                        <artifact>  
                            <groupId>commons-collections</groupId>  
                            <artifactId>commons-collections</artifactId>  
                            <version>3.2.2</version>  
                        </artifact>  
                        <moduleInfoSource>  
                            module commons.collections {  
                                requires java.desktop;  
  
                                exports org.apache.commons.collections;  
                                exports org.apache.commons.collections.bag;  
                                exports org.apache.commons.collections.bidimap;  
                                exports org.apache.commons.collections.buffer;  
                                exports org.apache.commons.collections.collection;  
                                exports org.apache.commons.collections.comparators;  
                                exports org.apache.commons.collections.functors;  
                                exports org.apache.commons.collections.iterators;  
                                exports org.apache.commons.collections.keyvalue;  
                                exports org.apache.commons.collections.list;  
                                exports org.apache.commons.collections.map;  
                                exports org.apache.commons.collections.set;  
                            }  
                        </moduleInfoSource>  
                    </module>  
  
                    <!--JMemoryBuddy-->  
                    <module>  
                        <artifact>  
                            <groupId>de.sandec</groupId>  
                            <artifactId>JMemoryBuddy</artifactId>  
                            <version>0.5.1</version>  
                        </artifact>  
                        <moduleInfoSource>  
                            module de.sandec.jmemorybuddy {  
                                requires java.management;  
                                requires jdk.management;  
  
                                exports de.sandec.jmemorybuddy;  
                            }  
                        </moduleInfoSource>  
                    </module>  
  
                    <!--commons-beanutils-->  
                    <module>  
                        <artifact>  
                            <groupId>commons-beanutils</groupId>  
                            <artifactId>commons-beanutils</artifactId>  
                            <version>1.9.4</version>  
                        </artifact>  
                        <moduleInfoSource>  
                            module commons.beanutils {  
                                requires transitive java.desktop;  
                                requires transitive java.sql;  
  
                                exports org.apache.commons.beanutils;  
                                exports org.apache.commons.beanutils.converters;  
                                exports org.apache.commons.beanutils.expression;  
                                exports org.apache.commons.beanutils.locale;  
                                exports org.apache.commons.beanutils.locale.converters;  
  
                            }  
                        </moduleInfoSource>  
                    </module>  
  
                </modules>  
            </configuration>  
        </execution>  
    </executions>  
</plugin>

1JavaFx应用打包

1.1 为不支持模块管理的包进行模块信息注入

当报错或警告自动模块,请不要将此库上传到公共仓库时使用

1.1.1生成jar包的module-info.java文件

首先cd当jar包所在目录,然后执行以下指令(jars是关键)

jdeps --ignore-missing-deps --generate-module-info jars [jar包名]

执行后会在当前目录生成jar文件夹,里面就是module-info.java文件

1.1.2 注入module-info.java文件并生成新的jar包

使用moditect插件可以方便的将一个包,变成一个模块

首先点击maven插件-- javafx-- javafx:jlink,查看哪些包不支持模块化然后针对那些包执行 《1.1.1》
配置好moditect,点击maven插件-- javafx-- javafx:jlink,即可在target下生成modules目录,里面就是已经注入模块信息的新jar包,使用新jar替换掉本地maven仓库的jar包

反复执行此过程,直到jlink成功,此时target下会生成app.zip压缩包,解压,打开bin,双击app.bat,就可以启动你的项目了

<plugin>  
    <groupId>org.moditect</groupId>  
    <artifactId>moditect-maven-plugin</artifactId>  
    <version>1.0.0.RC2</version>  
    <executions>  
        <execution>  
            <id>add-module-infos</id>  
            <phase>generate-resources</phase>  
            <goals>  
                <goal>add-module-info</goal>  
            </goals>  
            <configuration>  
                <outputDirectory>${project.build.directory}/modules</outputDirectory>  
                <!--覆盖重复文件,防止报错-->  
                <overwriteExistingFiles>true</overwriteExistingFiles>  
                <modules>  
  
                    <!--commons-digester-->  
                    <module>  
                        <artifact>  
                            <groupId>commons-digester</groupId>  
                            <artifactId>commons-digester</artifactId>  
                            <version>2.1</version>  
                        </artifact>  
  
                        <moduleInfoSource>  
                            module commons.digester {  
                            requires java.desktop;  
  
                            requires transitive java.xml;  
  
                            exports org.apache.commons.digester;  
                            exports org.apache.commons.digester.annotations;  
                            exports org.apache.commons.digester.annotations.handlers;  
                            exports org.apache.commons.digester.annotations.internal;  
                            exports org.apache.commons.digester.annotations.providers;  
                            exports org.apache.commons.digester.annotations.reflect;  
                            exports org.apache.commons.digester.annotations.rules;  
                            exports org.apache.commons.digester.annotations.spi;  
                            exports org.apache.commons.digester.annotations.utils;  
                            exports org.apache.commons.digester.parser;  
                            exports org.apache.commons.digester.plugins;  
                            exports org.apache.commons.digester.plugins.strategies;  
                            exports org.apache.commons.digester.substitution;  
                            exports org.apache.commons.digester.xmlrules;  
  
                            }  
                        </moduleInfoSource>  
                    </module>  
  
                    <!--commons-lang3-->  
                    <module>  
                        <artifact>  
                            <groupId>org.apache.commons</groupId>  
                            <artifactId>commons-lang3</artifactId>  
                            <version>3.13.0</version>  
                        </artifact>  
                        <moduleInfoSource>  
                            module org.apache.commons.lang3 {  
                                requires transitive java.desktop;  
  
                                exports org.apache.commons.lang3;  
                                exports org.apache.commons.lang3.arch;  
                                exports org.apache.commons.lang3.builder;  
                                exports org.apache.commons.lang3.compare;  
                                exports org.apache.commons.lang3.concurrent;  
                                exports org.apache.commons.lang3.concurrent.locks;  
                                exports org.apache.commons.lang3.event;  
                                exports org.apache.commons.lang3.exception;  
                                exports org.apache.commons.lang3.function;  
                                exports org.apache.commons.lang3.math;  
                                exports org.apache.commons.lang3.mutable;  
                                exports org.apache.commons.lang3.reflect;  
                                exports org.apache.commons.lang3.stream;  
                                exports org.apache.commons.lang3.text;  
                                exports org.apache.commons.lang3.text.translate;  
                                exports org.apache.commons.lang3.time;  
                                exports org.apache.commons.lang3.tuple;  
                                exports org.apache.commons.lang3.util;  
  
                            }  
  
                        </moduleInfoSource>  
                    </module>  
  
                    <!--javax.inject-->  
                    <module>  
                        <artifact>  
                            <groupId>javax.inject</groupId>  
                            <artifactId>javax.inject</artifactId>  
                            <version>1</version>  
                        </artifact>  
                        <moduleInfoSource>  
                            module javax.inject {  
                                exports javax.inject;  
                            }  
                        </moduleInfoSource>  
                    </module>  
  
                    <!--commons-collections-->  
                    <module>  
                        <artifact>  
                            <groupId>commons-collections</groupId>  
                            <artifactId>commons-collections</artifactId>  
                            <version>3.2.2</version>  
                        </artifact>  
                        <moduleInfoSource>  
                            module commons.collections {  
                                requires java.desktop;  
  
                                exports org.apache.commons.collections;  
                                exports org.apache.commons.collections.bag;  
                                exports org.apache.commons.collections.bidimap;  
                                exports org.apache.commons.collections.buffer;  
                                exports org.apache.commons.collections.collection;  
                                exports org.apache.commons.collections.comparators;  
                                exports org.apache.commons.collections.functors;  
                                exports org.apache.commons.collections.iterators;  
                                exports org.apache.commons.collections.keyvalue;  
                                exports org.apache.commons.collections.list;  
                                exports org.apache.commons.collections.map;  
                                exports org.apache.commons.collections.set;  
                            }  
                        </moduleInfoSource>  
                    </module>  
  
                    <!--JMemoryBuddy-->  
                    <module>  
                        <artifact>  
                            <groupId>de.sandec</groupId>  
                            <artifactId>JMemoryBuddy</artifactId>  
                            <version>0.5.1</version>  
                        </artifact>  
                        <moduleInfoSource>  
                            module de.sandec.jmemorybuddy {  
                                requires java.management;  
                                requires jdk.management;  
  
                                exports de.sandec.jmemorybuddy;  
                            }  
                        </moduleInfoSource>  
                    </module>  
  
                    <!--commons-beanutils-->  
                    <module>  
                        <artifact>  
                            <groupId>commons-beanutils</groupId>  
                            <artifactId>commons-beanutils</artifactId>  
                            <version>1.9.4</version>  
                        </artifact>  
                        <moduleInfoSource>  
                            module commons.beanutils {  
                                requires transitive java.desktop;  
                                requires transitive java.sql;  
  
                                exports org.apache.commons.beanutils;  
                                exports org.apache.commons.beanutils.converters;  
                                exports org.apache.commons.beanutils.expression;  
                                exports org.apache.commons.beanutils.locale;  
                                exports org.apache.commons.beanutils.locale.converters;  
  
                            }  
                        </moduleInfoSource>  
                    </module>  
  
                </modules>  
            </configuration>  
        </execution>  
    </executions>  
</plugin>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值