Use Ant to do one-click Deployment

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.