打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上

参考原文:Inno Setup打包 mysql+jdk+jar成exe文件,进行一键安装_恭维不起的博客-CSDN博客

百度网盘链接包含jdk8,mysql8,nginx,jar

百度网盘链接:https://pan.baidu.com/s/1hKIJb9TBJGuhhZAlRURmMw?pwd=7777
提取码:7777

battoexe_27027.zip和 innosetup-6.1.2.exe安装文件链接

链接:https://pan.baidu.com/s/1686lsYBLiO6S9XoiKoJOIA?pwd=7777
提取码:7777

补充:

一:mysql配置调整(因为可能mysql启动不起来)

配置文件目录:

打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第1张图片

my.ini文件

[client]
port=3308
[mysql]
default-character-set=utf8
[mysqld]
port=3308
character-set-server=utf8
default-storage-engine=INNODB
max_connections=100
table_open_cache=256
tmp_table_size=35M
thread_cache_size=8
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=69M
key_buffer_size=50M
read_buffer_size=64K
read_rnd_buffer_size=256K
sort_buffer_size=256K
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=1M
innodb_buffer_pool_size=96M
innodb_log_file_size=20M
innodb_thread_concurrency=18

myini.bat文件

echo
set CURRENT_DIR=%CD%
set CURRENT_DIR=%CURRENT_DIR:\=/%
echo basedir="%CURRENT_DIR%/">>my.ini
echo datadir="%CURRENT_DIR%/data/">>my.ini

启动停止mysql脚本目录:打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第2张图片

mysql_init.bat 执行了两个sql.并且加入开机自启动任务

cd /d %~dp0 

"%cd%\mysqld.exe" --initialize-insecure --user=mysql --console
echo -----mysql init succee-----

mysqld install mysql 
echo -----mysql service install succee-----

net start mysql
sc config mysql start=auto 
net stop mysql
net start mysql
echo Installation complete 

"%cd%\mysqladmin" -u root password 123456
echo Password change completed 
cd .. 

"%cd%\bin\mysql.exe" -uroot -p123456 < "%cd%\sql\create.sql" 

"%cd%\bin\mysql.exe" -uroot -p123456 < "%cd%\sql\green_finance_data_service.sql" 
echo Table creation completed 
echo Create new user completed
timeout /nobreak /t 10
exit

 mysql_stop.bat 停止删除任务命令:

@echo off
cd /d %~dp0
echo ----1.[Mysql] start uninstalling Mysql ---->>../log.txt
sc stop mysql
sc delete mysql
echo ----2. [Mysql] uninstall finished---- >>../log.txt
exit

二:Nginx相关

打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第3张图片

 nginx_init.bat启动脚本(后续打包启动有调整):

@echo off
cd /d %~dp0

echo ----1.start installing Nginx ---->>../log.txt

start nginx -c conf/nginx.conf

nginx_stop.bat 停止脚本:

@echo off
cd /d %~dp0

echo ----1.stop installing Nginx ---->>../log.txt

nginx.exe -s quit

echo ----1.kill Nginx ---->>../log.txt

taskkill /f /im nginx.exe > null

green_finance_data_service目录说明(前后端分离项目,前端vue打包的静态文件目录)

打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第4张图片

 nginx.conf目录:打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第5张图片

 三:project项目目录:

打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第6张图片

 start.bat启动脚本:该脚本经过Bat_To_Exe_Converter_(x64).exe转化后的内容

::[Bat To Exe Converter]
::
::YAwzoRdxOk+EWAnk
::fBw5plQjdG8=
::YAwzuBVtJxjWCl3EqQJgSA==
::ZR4luwNxJguZRRnk
::Yhs/ulQjdF+5
::cxAkpRVqdFKZSDk=
::cBs/ulQjdF+5
::ZR41oxFsdFKZSDk=
::eBoioBt6dFKZSDk=
::cRo6pxp7LAbNWATEpCI=
::egkzugNsPRvcWATEpCI=
::dAsiuh18IRvcCxnZtBJQ
::cRYluBh/LU+EWAnk
::YxY4rhs+aU+JeA==
::cxY6rQJ7JhzQF1fEqQJQ
::ZQ05rAF9IBncCkqN+0xwdVs0
::ZQ05rAF9IAHYFVzEqQJQ
::eg0/rx1wNQPfEVWB+kM9LVsJDGQ=
::fBEirQZwNQPfEVWB+kM9LVsJDGQ=
::cRolqwZ3JBvQF1fEqQJQ
::dhA7uBVwLU+EWDk=
::YQ03rBFzNR3SWATElA==
::dhAmsQZ3MwfNWATElA==
::ZQ0/vhVqMQ3MEVWAtB9wSA==
::Zg8zqx1/OA3MEVWAtB9wSA==
::dhA7pRFwIByZRRnk
::Zh4grVQjdCuDJFyc8X4gOhReSQeWAHiuB6cIpu3j6oo=
::YB416Ek+ZG8=
::
::
::978f952a14a936cc963da21a135fa983
start nginx_init.bat & start .\jdk1.8.0_121\bin\javaw -jar finance_jh-0.0.1-SNAPSHOT.jar & start .\jdk1.8.0_121\bin\javaw -jar finance_data-0.0.1-SNAPSHOT.jar & start .\jdk1.8.0_121\bin\javaw -javaagent:8996-encrypted.jar  -jar 8996-encrypted.jar > test.out 2>&1 & 

Bat_To_Exe_Converter_(x64).exe转换程序

打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第7张图片

Bat_To_Exe_Converter_(x64).exe转换前start.bat内容。转换后是start.exe文件该文件是生产DataView.exe可安装文件时生成的桌面快捷方式调用的启动jar和nginx的使用。其中:start nginx_init.bat是启动nginx的脚本放在这里的原因是防止每次重启电脑nginx服务不能使用;后面:start .\jdk1.8.0_121\bin\javaw -jar finance_jh-0.0.1-SNAPSHOT.jar 该脚本相当于linux nohup命令,可后台运行jar程序。

 打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第8张图片

 stop_port.bat(卸载时调用的脚本):第一行是获取管理员执行权限,然后for...命令是杀掉使用该端口的进程。

%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit

@echo off & setlocal EnableDelayedExpansion

for /f "tokens=5" %%b in ('netstat /ano ^| findstr 8210') do taskkill /F /pid %%b

for /f "tokens=5" %%c in ('netstat /ano ^| findstr 8996') do taskkill /F /pid %%c

for /f "tokens=5" %%f in ('netstat /ano ^| findstr 8212') do taskkill /F /pid %%f

四:介绍打包可安装文件相关

打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第9张图片

 green-finance-jh目录:是jar程序需要的一个路径存放上传的各种文件以及历史文件打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第10张图片

 file_init.bat脚本:从当前目录将所有的文件及子文件和目录复制到目标目录GenFolder下

@echo off
echo OutReport目录判断
SET SourceFolder="%cd%"
SET GenFolder=C:\green-finance-jh
 
Xcopy %SourceFolder% %GenFolder%  /s/e/h/i

file_stop.bat脚本(卸载使用):对应上面复制脚本,该脚本是删除folder下的所有文件

@echo off&cd /d "%~dp0"
set #=Any questions&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
set "folder=C:\green-finance-jh"
if not exist "%folder%" (echo;"%folder%" path error or not exist&pause&exit)
if "%folder:~-1%" equ "\" set "folder=%folder:~,-1%"
 
rem 方法一
rd /s /q "%folder%\"
md "%folder%\" 2>nul

 
echo;%#% +%$%%$%/%_% %z%
rd /q /s C:\green-finance-jh\
pause
exit

init_port.bat脚本:第一行获取管理权限,以下是看你所需要的端口是否被占用并且杀掉占用端口的进程。

%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit

@echo off & setlocal EnableDelayedExpansion

for /f "tokens=5" %%a in ('netstat /ano ^| findstr 3308') do taskkill /F /pid %%a

for /f "tokens=5" %%b in ('netstat /ano ^| findstr 8210') do taskkill /F /pid %%b

for /f "tokens=5" %%c in ('netstat /ano ^| findstr 8996') do taskkill /F /pid %%c

for /f "tokens=5" %%d in ('netstat /ano ^| findstr 8211') do taskkill /F /pid %%d

for /f "tokens=5" %%e in ('netstat /ano ^| findstr 8063') do taskkill /F /pid %%e

for /f "tokens=5" %%f in ('netstat /ano ^| findstr 8212') do taskkill /F /pid %%f

inno.iss打包程序文件:重要(文件内容可自行研究一下)

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
 
[Setup]
 
#define MyAppName "DataView"
#define MyAppVersion "1.0"
#define MyAppPublisher "海南省绿色发展投资有限公司"
#define MyAppURL "http://localhost:8211"
#define MyAppExeName "DataView.exe"
 
[Setup]
; (生成新的GUID,点凿工具|在IDE中生成GUID〿
AppId={{eccb021e-f776-459c-8cdb-81dd569f41d0}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir=D:\exeFinish
OutputBaseFilename=DataView
Compression=lzma
SolidCompression=yes
;AlwaysRestart=yes
;PrivilegesRequired=admin
 
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
 
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
 
[Files]
Source: "D:\exe\project\*"; DestDir: "{app}\project"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "D:\exe\nginx-1.22.1\*"; DestDir: "{app}\nginx-1.22.1"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "D:\exe\mysql-8.0.33-winx64\*"; DestDir: "{app}\mysql-8.0.33-winx64"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "D:\exe\green-finance-jh\*"; DestDir: "{app}\green-finance-jh"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion‿
 
[Icons]
Name: "{commondesktop}\绿色金融服务系统";Filename: "{app}\project\start.exe"; WorkingDir: "{app}\project"
 
[INI]
;修改数据库配置文仿
;Filename:"{app}\mysql-8.0.33-winx64\my.ini";Section:"mysqld";Key:"basedir"; String:"{app}\mysql-8.0.33-winx64"
 
;Filename:"{app}\mysql-8.0.33-winx64\my.ini";Section:"mysqld";Key:"datadir"; String:"{app}\mysql-8.0.33-winx64\data"
 
;Filename:"{app}\mysql-8.0.33-winx64\my.ini";Section:"mysqld";Key:"port"; String:"3308"
 
;Filename:"{app}\mysql-8.0.33-winx64\my.ini";Section:"client";Key:"port"; String:"3308"
 
[Run]                             

Filename: "{app}\green-finance-jh\file_stop.bat";

Filename: "{app}\green-finance-jh\file_init.bat";

Filename: "{app}\init_port.bat";

Filename: "{app}\mysql-8.0.33-winx64\bin\mysql_stop.bat";

Filename: "{app}\mysql-8.0.33-winx64\myini.bat";

Filename: "{app}\mysql-8.0.33-winx64\bin\mysql_init.bat";
 
[UninstallRun]
Filename: "{app}\project\stop_port.bat";

Filename: "{app}\mysql-8.0.33-winx64\bin\mysql_stop.bat";

Filename: "{app}\nginx-1.22.1\nginx_stop.bat";

Filename: "{app}\green-finance-jh\file_stop.bat";
 
[UninstallDelete]
 
Type:filesandordirs;Name:"{app}"

使用安装后的innosetup-6.1.2.exe打开inno.iss文件然后执行红框进行生成DataView.exe可安装程序。

打包jar,jdk8,,mysql8,nginx成exe可安装应用,进行一键安装windows系统上_第11张图片

最后提醒:生成的一键安装程序不要安装在c盘,切记切记切记。

你可能感兴趣的:(windows,windows,jar,java,一键安装)