1. Install the Alibaba Cloud Toolkit plug-in for IDEA.

  2. Select Tools -> Alibaba Cloud -> Deploy to Host, select the server, enter the directory to which the JAR package is to be uploaded and the command to execute after the upload. Sh), and then click Run. Note: Target Directory must have an upper end number (convention > configuration). In this example, all applications are deployed in /root/springboot-application and the script is executed in /root/springboot-application/deploy.sh.

  3. Sh is deployed as follows:

    #Delete old JAR packages (if any)
    rm -f application.jar application.log
    #Unified renaming
    mv *.jar application.jar
    #Get the port
    path=`pwd`
    port=`echo ${path#*:}`
    #Kill the original process (if any, an error will be reported if it is not executed without affecting the result)
    netstat -anp|grep ${port}|awk '{printf $7}'|cut -d/ -f1 |xargs kill -9 || true
    #Run in the background and save logs to application.log
    nohup java -jar application.jar > application.log 2>&1 &
    Copy the code
  4. If you want to deploy a new application, you can simply change the Target Directory without changing deploy.sh.