This topic describes how to publish an application on SOFAStack in classic publishing mode.
Prerequisites
You have completed the following preparations:
Register an Alibaba Cloud account and complete identity verification.
Step 1: Create an application service
An application can have multiple application services attached. In this Quick Start, you will create an application service for the new SOFABoot application and define its configuration.
Log on to the SOFAStack console.
In the navigation pane on the left, choose Operations Management > Classic Application Service > Application Publishing > Application Service.
Click Create Service Instance.
Configure the application service.
Application: Select the sofabootdemo application that you created in Create application metadata.
Service Instance Name: Enter sofabootdemo.
Deployment Package: Select the deployment package for the application.
NoteLeave this empty for now. You will upload the deployment package in Step 4: Publish the application.
Description: Enter a description for the service instance. Leave this empty for this example.
Technology Stack: This field is automatically populated based on the application. For this example, the value is SOFA Boot.
Technology Stack Version: Select a version.
Deployment Unit: Select the deployment unit where you want to publish the application.
Click OK.
Step 2: Purchase resources and attach them to the application service
In this step, you will purchase an ECS instance and a public-facing SLB instance for the sofabootdemo application service, and then attach the ECS instance to the SLB instance.
Purchase an ECS instance
Log on to the SOFAStack console.
In the navigation pane on the left, choose Operations Management > Classic Application Service > Application Publishing > Application Service.
In the service instance list, find the sofabootdemo application service that you created in the previous step. Click the instance name or Details to go to the Service Instance Information page.
On the ECS tab, click Add. Enter the required information as prompted and click Create to create the ECS instance.
Purchase a public-facing SLB instance
On the Service Instance Information page, click the SLB tab and then click Add.
On the page for creating a load balancer, enter the required information. Then, click OK and then Create to create the SLB instance.
Set Instance Type to Public Network.
In the Listener Information section, add a listener with the following settings:
Frontend Protocol: HTTP
Port: 80
Backend Protocol Port: 8341
Keep the default values for the other properties.
Attach the ECS instance to the SLB instance
After the ECS and SLB instances are created, attach them as follows:
On the SLB tab, click the name of the SLB instance that you just created to go to its details page.
In the Backend Server Group section, select the To Be Attached tab. Select the Same App checkbox, select the ECS instance that you created earlier, and click Attach.
In the Attach ECS window, set Traffic Weight to 100 and click OK.
After the attachment is complete, you can view the attached ECS instance on the Attached tab.
Step 3: Develop the application
For more information about how to develop an application locally using the SOFABoot framework, see SOFABoot Quick Start. For this example, you can skip the development process and directly download the sample JAR package and decompress it to your local machine. The applications in the sample project have been compiled and packaged locally. The generated package is in the target directory.
Step 4: Publish the application
Log on to the SOFAStack console.
In the navigation pane on the left, choose Operations Management > Classic Application Service > Application Publishing > Deployment Package Management.
In the application list, find sofabootdemo and click Manage to go to the deployment package management page. Then, click Upload Deployment Package.
In the dialog box that appears, use the default version number. For File, select the downloaded sample JAR package named sofa-boot-hello. Then, click Confirm.
After the upload is complete, you can view the uploaded version.
In the deployment package list, find the sofa-boot-hello.jar package that you just uploaded. In the Actions column, click Publish.
In the Publish Deployment dialog box, select the sofabootdemo service instance and the version that you just uploaded. Click Publish Now to go to the deployment order page for sofabootdemo.
On the deployment order page, click Publish All in the upper-right corner to start the publishing process for the sofabootdemo application. The application is published when the Status column shows Execution Succeeded.
On the application deployment order page, you can click the sofabootdemo application to view the deployment details of the application service instance.
Step 5: Verify the result
Verify that the application was published successfully.
Log on to the SOFAStack console.
In the navigation pane on the left, choose Operations Management > Classic Application Service > Application Publishing > Application Service. In the list, click sofabootdemo to go to the service instance details page.
On the SLB tab, copy the service endpoint.
You can access
http://{load balancer service endpoint:port number}/webapi/users/testerfrom a browser. For example,http://120.xx.xx.140:8080/webapi/users/tester.NoteThe port in
{load_balancer_endpoint:port}is the frontend protocol port of the SLB listener.If the port number is 80, you do not need to add it. Access
http://{load_balancer_endpoint}/webapi/users/testerdirectly.
If the page displays the following content, the application is published successfully:
{"data":{"realName":"Real tester","userId":0,"userName":"tester"},"success":true}