web项目打包exe文件-实现一键布署

一、准备需要拷贝的文件

文件目录:包括jdk、mysql、tomcat、redis

 

(1).Mysql文件夹

 

准备my.ini

-----------------------------------------------------------------------------

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

# *** default location during install, and will be replaced if you

# *** upgrade to a newer version of MySQL.

 

[mysqld]

 

character_set_server=utf8

 

 

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

 

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

 

# These are commonly set, remove the # and set as required.

# basedir = .....

# datadir = .....

port = 3306

# server_id = .....

 

 

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

 

[client]

port=3306

default-character-set=utf8

[mysql]

default-character-set=utf8

 

Mysql bin目录

 

准备startServer.bat

---------------------------------------------------------------------------------------------

cd /d %~dp0

"%cd%\mysqld.exe" -install

net start mysql

--------------------------------------------------------------------------------------------

注:mysql 安装需要依赖 visual C++2013 Redistributable(X64)

下载地址:

https://download.microsoft.com/download/F/3/5/F3500770-8A08-488E-94B6-17A1E1DD52 6F/vcredist_x64.exe

 

  1. .Tomcat8文件夹:

 

准备文件Set_Env.bat

----------------------------------------------------------------------------------------

@echo off

echo

cd ..

echo "%~dp0"

echo "%cd%"

set jdkpath=%cd%\tomcat8\bin\Java\jdk1.8.0_171

echo %jdkpath%

setx JAVA_HOME "%jdkpath%" -m

setx CLASS_PATH ".;%%JAVA_HOME%%\lib\tools.jar;%%JAVA_HOME%%\lib\dt.jar" -m

echo %Path%

echo %Path%|find /i "%java_home%" && set IsNull=true || set IsNull=false

echo %IsNull%

if not %IsNull%==true (

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"/vPath/tREG_SZ/d %Path%;%%JAVA_HOME%%\bin;%%JAVA_HOME%%\jre\bin" /f

setx Path "%%JAVA_HOME%%\bin;%Path%"

)

Exit

-------------------------------------------------------------------------------------------------------------

Tomcat bin目录

 

  1. . jdk目录放在tomcat bin目录下

 

Jdk文件夹

 

  1. .Redis文件夹

 

准备startServer.bat文件

------------------------------------------------------------------------------------------

redis-server.exe redis.windows.conf

-------------------------------------------------------------------------------------------

 

二、打包工具

在网上下载一个 Inno steup的制作exe文件工具

 

用脚本向导创建新的脚本文件

确定后,根据向导填入程序信息

 

这一步选择应用程序没有主执行文件,点击添加文件夹,选择mysql、tomcat、redis等所在文件夹

完成后生成脚本大致如下:

 

---------------------------------------------------------------------------------

; 脚本由 Inno Setup 脚本向导 生成!

; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

 

#define MyAppName "XXXXXXXX系统"

#define MyAppVersion "2.2"

#define MyAppPublisher "XXXX股份有限公司"

#define MyAppURL "http://www.shlanbao.cn/"

 

[Setup]

; 注: AppId的值为单独标识该应用程序。

; 不要为其他安装程序使用相同的AppId值。

; (生成新的GUID,点击 工具|在IDE中生成GUID。)

AppId={{CA21D414-F0D6-4CF0-BAB6-29AC9B20E218}

AppName={#MyAppName}

AppVersion={#MyAppVersion}

;AppVerName={#MyAppName} {#MyAppVersion}

AppPublisher={#MyAppPublisher}

AppPublisherURL={#MyAppURL}

AppSupportURL={#MyAppURL}

AppUpdatesURL={#MyAppURL}

DefaultDirName=D:\lbims

DefaultGroupName={#MyAppName}

AllowNoIcons=yes

OutputDir=C:\Users\Administrator\Desktop\Output

OutputBaseFilename=setup

SetupIconFile=C:\Users\Administrator\Desktop\favicon.ico

Compression=lzma

SolidCompression=yes

 

[Languages]

Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

 

[Files]

Source: "D:\app\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

; source  指定tomcat、mysql等文件夹所在的上级文件夹

 

[Icons]

Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"

; 下面三行定义在桌面生成三个图标,可根据需要自行增删

Name: "{commondesktop}\XXXXXX系统"; Filename: http://localhost:8080/mes_sys

Name: "{userdesktop}\启动服务"; Filename: "{app}\tomcat8\bin\startup.bat";

Name: "{userdesktop}\关闭服务"; Filename: "{app}\tomcat8\bin\shutdown.bat";

 

[Run]

; 指定安装需要运行的文件,runhidden 指定在后台静默运行

Filename: "{app}\tomcat8\Set_Env.bat"; Flags: runhidden;

Filename: "{app}\mysql\bin\startServer.bat"; Flags: runhidden;

Filename: "{app}\Redis\installServer.bat"; Flags: runhidden;

准备就绪后,构建-编译

 

 

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值