Quickly deploy a springboot project based on function computing custom runtime

What is function calculation?

Function calculation is an event-driven fully managed computing service. Using function calculation, you do not need to purchase and manage infrastructure such as servers, but just write and upload code. Function calculation prepares computing resources for you, runs tasks elastically and reliably, and provides log query, performance monitoring and alarm functions. With function calculation, you can quickly build any type of applications and services, and only pay for the resources actually consumed by the task.

Development steps

1. Opening function calculation

Before opening, you need to register your AliCloud account and complete real-name authentication to enter the function calculation official website https://fcnext.console.aliyun.com If you have not yet opened function calculation, you need to check the function calculation service agreement on the function calculation opening page and click Open Now. After opening, you will automatically jump to the function calculation console.

2. Create a new service

Click "Service and Function" on the function calculation console to enter the service list, click Create Service in the service list, fill in the service configuration, and click OK to create the service. Note: turning on the log and link tracking functions can make it easier to debug code, analyze faults, analyze data, and view the internal time consumption of the function (it is recommended to turn it on, but some fees may be charged).

3. Create a new function

Click the created service name under the service list to enter the function management page, click Create Function, select "Create with Custom Runtime" on the function creation page to fill in the relevant configuration of the function, select the sample template function of Java 17 in the running environment, and after the configuration is completed, the page will drop down to the bottom and click Create to deploy a spring boot project.

4. Custom domain name configuration

After the function is created, directly open the request address in the browser, and the response will be downloaded as an attachment. This is because the Http trigger will automatically add the Content-Disposition: attachment field in the response header. We can use the custom domain name to avoid this problem. Enter the domain name management page, click Add Custom Domain Name, and select the service and function you created in the routing configuration. After the configuration is completed, you can enter the configured domain name in the browser, and you can see the Hello World displayed on the page! The deployment configuration of a simple spring boot project is completed.

5. Development

• Export code

To continue the project development, we can enter the details page of the function in the function calculation console and use online IED to develop and debug the function code page, or export the function code in "Export Function" and use our own code editor for development.

• Code structure

•pom.xml

•DemoApplication

• Configure listening port

Add a listening port in the application.properties configuration file. The configuration port here needs to be consistent with the listening port configured by the function

summary

This experience uses function computing to deploy a spring boot project. In general, the process is very smooth. A project can be generated and deployed only at the console point. It is very friendly for novices. It saves a lot of environment building and installation dependencies when deploying traditional projects. It can really let us focus on the development of business logic!

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us