Deploy a Java Web project to a remote server in a way that was often used before:
1. Export the Project War package on eclipse
2. Upload the war package to the server via FTP, such as Tomcat's WebApps directory
3, start Tomcat, automatically unzip the war file, generate the folder of the project, this time the deployment is complete
The above steps are the initial deployment project, if you want to redeploy the project, then close Tomcat, delete the original project folder (including the original war file), and then repeat the above steps.
If you want to deploy a server has more than one, so the operation must be exhausted, and it is easy to operate error.
In fact, you can use ant to do one-click deployment, such as the Build.xml file
<?XML version= "1.0" encoding= "UTF-8"?><Projectname= "disconf"Basedir="."default= "Upload"> <Targetname= "Upload"depends= "Remove"> <SCPTodir= "Root:[email protected]:/data/apache-tomcat-8.0.35/webapps/disconf-web.war"file= "D:/deploy/disconf-web.war"Trust= "true" > </SCP> </Target> <Targetname= "Remove"> <sshexecHost= "192.168.0.24"username= "root"Password= "B4gjqxtshlneckqs"Trust= "true"Command= "Rm-f/data/apache-tomcat-8.0.35/webapps/disconf-web.war; Rm-rf/data/apache-tomcat-8.0.35/webapps/disconf-web; "> </sshexec> </Target></Project>
In the ant task above, there are only two target:
Remove is the removal of the server's original file, which uses Sshexec to execute the shell command on the server, as well as the close Tomcat service to command, with each command separated by semicolons
upload is to upload the war package to the server, using the SCP, this feature requires the third-party jar Jsch outside Ant, if the ant command is executed on Eclipse, will prompt the missing Jsch jar package
Automated Deployment Tools
In addition to ant, other one-click Deployment features can also be used with Maven's Tomcat plugin, and Jenkins
Use Ant to do one-click Deployment