Deploy a Java application developed locally with the Cloud Toolkit to an Alibaba Cloud ECS instance

This tutorial will show you how to deploy a locally developed ** Java ** application to a ** Alibaba Cloud ECS instance ** using the Cloud Toolkit.

With the rapid development of cloud computing technology, more and more developers are deploying applications to Alibaba Cloud Elastic Compute Service (ECS) instances. .. In this tutorial, you will deploy a locally developed Java application to your Alibaba Cloud ECS instance using the Cloud Toolkit (https://www.aliyun.com/product/cloudtoolkit_en?spm=a2c65.11461447.0.0.5c512950XiQYjf). I will explain how.

image.png

Develop an application locally

Whether you compile a Java application that runs in the cloud or a Java application that runs locally, the coding method is the same. Therefore, in this article, we will explain how to deploy using a Java Servlet for printing "Hello World" on a Web page as an example.

image.png

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;
    }}

[This link](https://alicloud-common.oss-ap-southeast-1.aliyuncs.com/Cloud_Toolkit_Blog/IndexSer...%5B%E9%93%B6%E6%97%B6%5D.1540514368. You can download the source code from zip? spm = a2c65.11461447.0.0.5c512950XiQYjf & file = IndexSer ...% 5B% E9% 93% B6% E6% 97% B6% 5D.1540514368.zip).

The above code is a standard Java project for displaying the string "Hello World" on a web page.

Plugin installation

Alibaba Cloud provides Eclipse-based plugins that allow developers to efficiently deploy applications written in their local IDE to ECS instances.

Plugin URL: https://www.aliyun.com/product/cloudtoolkit_en

The procedure for installing this Eclipse-based plug-in is similar to a typical plug-in, so we won't go into details here.

Plugin preferences

After installing the plugin, select it and configure the preferences.

Top Menu> Window> Preferences> Alibaba Cloud Toolkit> Account

When the following page is displayed, set the AK and SK of the Alibaba Cloud account, and the setting of the environment setting is completed (If you are using a RAM user account, enter the AK and SK of the RAM user ).

image.png

Deploy application

image.png

Right-click on the project name in Eclipse and select Alibaba Cloud> Deploy to ECS from the shortcut menu. The following deployment screen will be displayed.

image.png

In the Placement Settings dialog box, set the placement parameters and click Placement to complete the initial placement.

Description of placement parameters

--Deployment file: There are two options. --Maven Build: If you are using Maven to build your current project, you can use Alibaba Cloud Toolkit to build and deploy your application directly. --File Upload: If you are not using Maven to build your current project, or if you already have a locally packaged deployment file, you can select your local deployment file and upload it directly. --Select ECS to deploy: Select a region from the drop-down list and select the ECS instance to deploy to that region. --Specify deployment destination: Enter the deployment path on the ECS instance. --Command: Enter the application startup command. This parameter specifies the command to be executed after the application package is deployed. For Java programs, this is usually the Tomcat start command.

Recommended Posts

Deploy a Java application developed locally with the Cloud Toolkit to an Alibaba Cloud ECS instance
Deploy a Node.js application to an ECS instance using the Cloud Toolkit
Deploy Java application developed in IntelliJ IDEA environment to Alibaba Cloud ECS instance
How to develop an app with Jersey Java RESTful API on Alibaba Cloud ECS instance
Guide: Deploy your application using the Alibaba Cloud Toolkit plugin
How to deploy Java application to Alibaba Cloud EDAS in Eclipse
Deploy your application to EDAS using the Cloud Toolkit Maven plugin
How to deploy a system created with Java (Wicket-Spring boot) to an on-campus server
I tried to modernize a Java EE application with OpenShift.
Continuous integration on Alibaba Cloud ECS Ubuntu instance with Jenkins
[Java] Deploy the Spring Boot application to Azure App Service
Initialization with an empty string to an instance of Java String type
How to build an environment with Docker, which is the minimum required to start a Rails application
[Java] How to search for a value in an array (or list) with the contains method
[Java] Adding an element to the Collection causes a compile error
Connecting to a database with Java (Part 1) Maybe the basic method
Automatically deploy a Web application developed in Java using Jenkins [Preparation]
Replace with a value according to the match with a Java regular expression
I tried to make an Android application with MVC now (Java)
Deploy a Docker application with Greengrass
Run an application made with Java8 with Java6
[Java] How to turn a two-dimensional array with an extended for statement
Automatically deploy a web application developed in Java using Jenkins [Spring Boot application]
[Java] Deploy a web application created with Eclipse + Maven + Ontology on Heroku
I want to ForEach an array with a Lambda expression in Java
How to make an app with a plugin mechanism [C # and Java]
Send a request to the backend after authenticating with Spring Cloud Gateway
[AWS] How to automatically deploy a Web application created with Rails 6 to ECR / ECS using CircleCI ① Preparation [Container deployment]
Let's make a calculator application with Java ~ Create a display area in the window
It took a month from application to taking the Oracle Java SE 11 Silver
Until you run a Java program with the AWS SDK local to Windows
From creating a Spring Boot project to running an application with VS Code
Let's create a TODO application in Java 12 Processing when a request comes in with an unused HttpMethod ・ Processing when an error occurs in the server
Install NextCloud on CentOS 7 with Alibaba Cloud ECS
Connect to Aurora (MySQL) from a Java application
Deploy Java web app to Azure with maven
Deploy Rails to ECS Fargate with AWS Copilot
[Java / PostgreSQL] Connect the WEB application to the database
How to use Alibaba Cloud LOG Java Producer
I tried to break a block with java (1)
How to save a file with the specified extension under the directory specified in Java to the list
[Azure] I tried to create a Java application for free ~ Connect with FTP ~ [Beginner]