一自动升级配置
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>