Deploying a Java Application to an ECS Instance in IntelliJ IDEA

In the previous article, we have discussed how to deploy a local Java application directly to an Alibaba Cloud ECS instance. We have also seen how to use this plug-in to deploy applications on Enterprise Distributed Application Service (EDAS). This tutorial explains how to deploy a Java application that is developed in a local IntelliJ IDEA environment to an Alibaba Cloud ECS instance.

Image for post
Image for post

Develop an Application Locally

The coding method is similar no matter whether you compile Java applications that run on the cloud or locally. Therefore, this article takes a Java servlet for printing “Hello World” on a Web page as an example to explain the deployment method.

Image for post
Image for post
public class IndexServlet extends HttpServlet {
private static final long serialVersionUID = -112210702214857712L;
@Override
public void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
PrintWriter writer = resp.getWriter();
// Demo: Use Alibaba Cloud Toolkit to modify the code of a local application and deploy the application to the cloud.
writer.write("Deploy from alibaba cloud toolkit. 2018-10-24");
return;
}
@Override
protected void doPost( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
return;
}}

Install Plug-in

Alibaba Cloud provides an Intellij IDEA-based plug-in to help developers efficiently deploy applications written in the local IDE to ECS instances.

Configure the Plug-in Preferences

After installing the plug-in, click the Alibaba Cloud icon on the toolbar, as shown in the figure below.

Image for post
Image for post
Image for post
Image for post

Deploy the Application

Image for post
Image for post
Image for post
Image for post

Description of Deployment Parameters

  • Deploy File: Two options are available.
  • Maven Build: If Maven is used to build the current project, you can use Alibaba Cloud Toolkit to directly build and deploy the application.
  • Upload File: If Maven is not used to build the current project, or a locally packaged deployment file already exists, you can select and directly upload the local deployment file.
  • Target Deploy ECS: Select a region from the drop-down list, and then select the ECS instance to be deployed in the region.
  • Deploy location: Enter the deployment path on the ECS instance, for example, /root/tomcat/webapps.
  • Command: Enter the application startup command, for example, sh /root/restart.sh. This parameter specifies the command to be executed after the application packa

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store