Serverless rapid development and deployment of a Hello World (Java version)

Yesterday I was attracted by this cool big screen of Alibaba Cloud!

Serverless rapid development and deployment of a Hello World

I waited for so few developers after 85! Very curious about what kind of ghosts are all post-90s and 95s playing? Just took a closer look.

This is an experience event about Serverless. Serverless has always been in a tepid state in China, so many developers actually don't know what Serverless is!

If you have this kind of curiosity, you can experience it like me. Simply write a Hello World and have the most intuitive experience of this futuristic product!

PS Participate in the event and join the DingTalk group, and you can also draw once a day. You have the opportunity to win AirPods, Gundam PG model (my favorite), Cherry mechanical keyboard and other rich gifts!

Serverless rapid development and deployment of a Hello World

 

How to participate

-[Official] Event Homepage: developer.aliyun.com/topic/yiqi/... -[Official] Customs Clearance Book: help.aliyun.com/document_de...

The official documents still need to be improved like other Ali projects (lan)...

If you have enough confidence in your own exploration ability, you can try it directly through the official documentation.

If you want to avoid the pits, you can read the super detailed customs clearance book I wrote below to complete a Java version of Hello World!

Step 1: Enter the product list and click Create Application

Serverless rapid development and deployment of a Hello World

 

Step 2: Select the "Empty Application" tab

  • Serverless application server selection: "Functional Computing FC"
  • Development language selection: Java

Serverless rapid development and deployment of a Hello World

 

Step 3: Fill in the application name and application introduction, just define it yourself

Serverless rapid development and deployment of a Hello World

 

Step 4: Click the "Development and Deployment" button in the newly created application card

Serverless rapid development and deployment of a Hello World

 

Step 5: Create new helloworld.java

Serverless rapid development and deployment of a Hello World

 

The content is as follows:

<protostuff.version>1.7.2</protostuff.version>
<dependency>
    <groupId>io.protostuff</groupId>
    <artifactId>protostuff-core</artifactId>
    <version>${protostuff.version}</version>
</dependency>
<dependency>
    <groupId>io.protostuff</groupId>
    <artifactId>protostuff-runtime</artifactId>
    <version>${protostuff.version}</version>
</dependency>

Step 6: Operate as shown below to submit the code

Serverless rapid development and deployment of a Hello World

Step 7: Deploy the application to the daily environment

Click the first icon in the left toolbar to enter the deployment interface, and click "Add a Route".

Serverless rapid development and deployment of a Hello World

The content of the two parts in the figure is: com.alibaba.serverless.helloworld.helloworld::handleRequest, which corresponds to the handleRequest method in the previously created helloworld.java, which means that the /helloworld request will be processed by the handleRequest in this class.

Note that the request method should be set to POST, I will explain why later!

Step 8: Test the /helloworld interface

There is a test tool next to the deployment tab, enter the user path/helloworld, click test to initiate a request, and the result is shown in the following figure:

Serverless rapid development and deployment of a Hello World

Looking back at the code, the body content used:

Serverless rapid development and deployment of a Hello World

 

Does this test tool always feel a little weird? ! Yes, there is no choice of HTTP Request Method. This request is sent by POST by default, so in the previous step we configured /helloworld as a POST request, otherwise it will not succeed. Brothers who read the official collection, have you found this pit?

How is it? Did your first serverless journey go smoothly?

If you think this article is helpful to you, you can pay attention to support it, and everyone can learn and make progress together!

Guess you like

Origin blog.csdn.net/weixin_48182198/article/details/108532257