Windows 一键安装部署Tomcat+MySQL

最近做了一个进销存系统,尝试单机部署应用,为方便部署需要一键安装部署。

实现目标:

  1. Tomcat服务自动启动
  2. Tomcat依赖JDK必须配置完整
  3. MySQL服务自动启动
  4. Web应用可以访问

Tomcat配置

service.bat配置文件完成配置JAVA_HOME路径、自动启动服务

set "JAVA_HOME=%~dp0%jdk8"
:installed
echo The service '%SERVICE_NAME%' has been installed.
sc config Tomcat8 start=auto
net start Tomcat8

启动关闭服务脚本

"%~dp0%service.bat" install


netsh advfirewall firewall delete rule name="Tomcat8 port" dir=in protocol=TCP localport=8080
echo close port success
net stop tomcat8
sc delete tomcat8

MySQL配置

启动脚本

rem cd /d %~dp0

set "myini=%~dp0%..\my.ini"

echo %myini%

"%~dp0%mysqld.exe" ^
  --initialize-insecure ^
  --user=mysql

"%~dp0%mysqld.exe" ^
  --install "MySQL_Fresh" ^
  --defaults-file="%myini%"

net start MySQL_Fresh

sc config MySQL_Fresh start=auto

echo 安装完毕

%~dp0%mysqladmin -u root password fresh
echo 修改密码完毕

set "c_sql=%~dp0%..\cfg\createbase.sql"

"%~dp0%mysql.exe" ^
  -uroot ^
  -pfresh < "%c_sql%"

"%~dp0%mysql.exe" ^
  -uroot ^
  -pfresh < "%~dp0\..\cfg\fresh.sql"

echo 建表完毕

"%~dp0%mysql.exe" ^
  -uroot ^
  -pfresh < use fresh < "%~dp0\..\cfg\user.sql"

echo 建立新用户完毕
rem pause

关闭服务

net stop MySQL_Fresh
sc  delete MySQL_Fresh

echo 卸载完成

rem pause

一键打包

Inno Setup 可以实现在Windows上一键安装的软件,只需配置好安装界面脚本。

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "蚂蚁采购配送系统"
#define MyAppVersion "1.0"
#define MyAppPublisher "ziguo, Inc."
#define MyAppURL "https://blog.csdn.net/huaishu/article/details/107541158"
#define MyAppExeName "MyProg.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{22FE6F9D-4B8F-4134-BDA9-D7F242FBCF8E}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\antwk
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputBaseFilename=myAntwk
Compression=lzma
SolidCompression=yes
WizardStyle=modern
SetupIconFile=D:\install_pro\install\favicon3.ico

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "cn"; MessagesFile: "compiler:Languages\ChineseSimplified.isl";

[Files]
Source: "D:\Program Files (x86)\Inno Setup 6\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\install_pro\install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"

[Run]
Filename: "{app}\mysql-5.7.30\bin\start_mysql.bat";
Filename: "{app}\apache-tomcat-8.0.30\bin\start_service.bat";

[UninstallRun]
Filename: "{app}\mysql-5.7.30\bin\stop_mysql.bat";
Filename: "{app}\apache-tomcat-8.0.30\bin\stop_service.bat";

 

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页