Springboot + javaFX + fxlauncher + exe4j 程序自动升级功能

一自动升级配置

1、导入jar包

		<dependency>
            <groupId>no.tornado</groupId>
            <artifactId>fxlauncher</artifactId>
            <version>1.0.20</version>
        </dependency>
        <dependency>
            <groupId>org.controlsfx</groupId>
            <artifactId>controlsfx</artifactId>
            <version>8.40.11</version>
        </dependency>


2、在properties中配置

		<!-- 名称 -->
		<app.filename>name</app.filename>
        <!--运行的主类  在使用exe4j打包成exe后,运行javafx程序需要调用JarLauncher类-->
        <app.mainClass>org.springframework.boot.loader.JarLauncher</app.mainClass>
        <!--FXLauncher运行后文件下载文件保存的位置-->
        <app.cacheDir>./bin</app.cacheDir>
        <!--FXLauncher运行时候的参数,比如什么更新失败后继续打开程序之类的,有哪些看官方的Readme里面-->
        <app.parameters>--myOption=myValue --myOtherOption=myOtherValue</app.parameters>
        <app.vendor>Acme Inc</app.vendor>
        <app.version>3.0</app.version>

        <!--更新文件的服务器地址,在这里可以打开下载你的更新jar包就行,tomcat和apache都行-->
        <app.url>http://127.0.0.1:8080/</app.url>
        <!--编译后的位置,这个位置在Idea里面是target下面的app目录-->
        <app.dir>${project.build.directory}/app</app.dir>
        <!--打包exe程序后的目录位置target/install-->
        <app.installerdir>${project.build.directory}/installer</app.installerdir>
        <!--是否接受版本降级-->
        <app.acceptDowngrade>true</app.acceptDowngrade>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

3、配置build

<build>
        <plugins>
            <plugin>
            	<!-- 使用springboot打包成一个jar -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                	<!--jar包保存路径-->
                    <outputDirectory>${app.dir}</outputDirectory>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <configuration>
<!--                    <excludeScope>provided</excludeScope>-->
                    <outputDirectory>${app.dir}</outputDirectory>
                    <stripVersion>true</stripVersion>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>no.tornado</groupId>
                                    <artifactId>fxlauncher</artifactId>
                                    <version>1.0.20</version>
                                    <outputDirectory>${app.dir}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.0.0</version>
                <!-- 生成 app.xml manifest -->
                <executions>
                    <execution>
                        <id>create-manifest</id>
                        <phase>package</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>fxlauncher.CreateManifest</mainClass>
                            <arguments>
                                <argument>${app.url}</argument>
                                <argument>${app.mainClass}</argument>
                                <argument>${app.dir}</argument>
                                <argument>--cache-dir=${app.cacheDir}</argument>
                                <argument>--accept-downgrade=${app.acceptDowngrade}</argument>
                                <!--这里可以放你想要更新文件打包进去的文件 比如dll,db之类的,可以事先放在app目录下-->
                                <argument>--include-extensions=jpg</argument>
                                <argument>${app.parameters}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <!-- 把app.xml打包进fxlauncher.xml,这样就启动器就不需要依赖app.xml来启动了 -->
                    <execution>
                        <id>embed-manifest-in-launcher</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>jar</executable>
                            <workingDirectory>${app.dir}</workingDirectory>
                            <arguments>
                                <argument>uf</argument>
                                <argument>fxlauncher.jar</argument>
                                <argument>app.xml</argument>
                            </arguments>
                        </configuration>
                    </execution>
                   <!-- <execution>
                        <id>installer</id>
                        <phase>install</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>javapackager</executable>
                            <arguments>
                                <argument>-deploy</argument>
                                <argument>-native</argument>
                                <argument>-outdir</argument>
                                <argument>${app.installerdir}</argument>
                                <argument>-outfile</argument>
                                <argument>${app.filename}</argument>
                                <argument>-srcdir</argument>
                                <argument>${app.dir}</argument>
                                <argument>-srcfiles</argument>
                                <argument>fxlauncher.jar</argument>
                                <argument>-appclass</argument>
                                <argument>fxlauncher.Launcher</argument>
                                <argument>-name</argument>
                                <argument>${project.name}</argument>
                                <argument>-title</argument>
                                <argument>${project.name}</argument>
                                <argument>-vendor</argument>
                                <argument>${app.vendor}</argument>
                                <argument>-BappVersion=${app.version}</argument>
                                <argument>-Bidentifier=${project.groupId}.${project.artifactId}</argument>
                            </arguments>
                        </configuration>
                    </execution>-->
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

4、使用idea进行package

在这里插入图片描述

二、exe4j打包exe

(1)、使用将jar打包成exe

在这里插入图片描述

(2)、设置打包路径

在这里插入图片描述

(3)、设置程序名称(图标也可以设置)在这里插入图片描述

(4)、选择程序位数在这里插入图片描述

(5)、选择jar包

在这里插入图片描述

(6)、选择启动入口在这里插入图片描述

(7)、选择jre在这里插入图片描述在这里插入图片描述

(8)、在这里插入图片描述

(9)、选择jre版本号

在这里插入图片描述

(10)、一直Next

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值