1.首先下载两个工具:

  1. exe4j,一个将jar转换成exe的工具
  2. inno setup,一个将依赖和exe一起打成一个安装程序的工具

链接:https://pan.baidu.com/s/1zovXMT3rAtHa3TXY9d18sg
提取码:k3ma

2.maven把Springboot项目打包

可以在idea的Terminal中直接输入命令:

mvn clean package

记录一次Springboot项目打包成exe

或者用idea右侧的maven工具

记录一次Springboot项目打包成exe

 打包成功后到target目录下找到jar包,为了方便我就直接拖到了桌面上

记录一次Springboot项目打包成exe

3.打包成exe

先把exe4j.rar解压,根据自己系统版本运行安装程序,直接下一步到底,安装后运行。

 记录一次Springboot项目打包成exe

 

记录一次Springboot项目打包成exe

 

 

 记录一次Springboot项目打包成exe

 

 

 记录一次Springboot项目打包成exe

 

 

 下方有个Advanced Options选项,需要设置打包后的程序兼容32和64位系统

记录一次Springboot项目打包成exe

 

 

 记录一次Springboot项目打包成exe

 

 

 然后下一步,直到出现下面的界面,开始选择jar包以及配置 在VM参数配置的地方加上:-Dfile.encoding=utf-8,然后点击加号选择自己Springboot项目的jar包。

记录一次Springboot项目打包成exe

 

 

 记录一次Springboot项目打包成exe

 然后点击Main class 后面的三个点

 记录一次Springboot项目打包成exe

 

 选择如图的启动类

记录一次Springboot项目打包成exe

 

 点击下一步

记录一次Springboot项目打包成exe

 

 记录一次Springboot项目打包成exe

 

 点击加号如图输入,这样写的目的是,最终会把本地jre目录和exe一起打包,让exe文件自己去根据路径去查找一起打包的jre,可不用再安装jdk。

记录一次Springboot项目打包成exe

 

 接着下一步

记录一次Springboot项目打包成exe

 

 记录一次Springboot项目打包成exe

 

 接着一直下一步直到出现下面这个界面

记录一次Springboot项目打包成exe

 

 这个时候exe就制作完成了,可以看到桌面上有了一个exe文件,先不着急运行,点击exit退出程序,他会让你保存配置,这个就看你自己了。

4.将exe和jre封装成安装程序

点击innosetup-5.6.1.exe进行安装,然后运行。

左上角File - New

记录一次Springboot项目打包成exe

 

 

记录一次Springboot项目打包成exe

 

 记录一次Springboot项目打包成exe

 

 点击下一步,这里默认即可

记录一次Springboot项目打包成exe

 

 记录一次Springboot项目打包成exe

 

 点击下一步

记录一次Springboot项目打包成exe

 

 记录一次Springboot项目打包成exe

 

 记录一次Springboot项目打包成exe

 

 记录一次Springboot项目打包成exe

 

 记录一次Springboot项目打包成exe

 

记录一次Springboot项目打包成exe

 

 配置到最后一步了,脚本文件,到这里会弹出问你是否马上编译,选择否,先把脚本写好再自己编译

记录一次Springboot项目打包成exe

 

在下图位置加一行代码  #define MyJreName "jre" 

记录一次Springboot项目打包成exe

 

 

 

 在[Files]下加一行代码

 Source: "自己本地JRE路径\*"; DestDir: "{app}\{#MyJreName}"; Flags: ignoreversion recursesubdirs createallsubdirs 

记录一次Springboot项目打包成exe

 

 脚本修改后,点击执行。

 记录一次Springboot项目打包成exe

 

 会弹框问你是否保存这个脚本是否保存,根据自己需求选择。

等待完成后会弹出安装程序,桌面上也会多一个exe。

我们直接把他安装,并且创建快捷方式看是否能运行。

记录一次Springboot项目打包成exe

 

 这样就可以了。我们打开浏览器再测试一下,成功出现页面。

 记录一次Springboot项目打包成exe

 

相关文章:

  • 2021-12-25
  • 2021-09-29
  • 2021-08-01
  • 2021-11-20
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
猜你喜欢
  • 2021-10-30
  • 2021-08-01
  • 2022-01-14
  • 2021-10-25
  • 2021-09-19
  • 2021-09-01
相关资源
相似解决方案