This article shows you how you can build a SpringBoot Application on Alibaba Cloud using Function Compute and the Fun (Funcraft) tool.
First, let's take a look at the definitions of some key terms used in this article:
- Function Compute: is an event-driven service that allows users to write and upload code without having to manage server health or consider other factors. After Function Compute allocates required computing resources, it elastically runs your code. The fees of using these resources are billed based on their actual consumption. For more information about Function Compute, visit the official product page.
- Fun: is a developer tool for serverless applications. It helps you manage resources such as Function Compute, API Gateway, and Log Service. You can use Fun to develop, build, and deploy resources by describing them in the template.yml file. For more information about Fun, click here.
- ROS (Resource Orchestration Service): helps you simplify the management of cloud computing resources. By following the template specifications defined by ROS, you can define the collection of required cloud computing resources and their dependencies. ROS automatically creates and configures all resources to implement automated deployment and O&M. For more documents on ROS, visit the official product page.
First, follow the Fun installation documentto install Fun on your local computer.
After the installation is completed, run
fun --version to check that Fun has been successfully installed.
1. Initialize a project
fun initto initialize a project.
fun init -n SpringBootDemo
After the initialization is completed, a directory named SpringBootDemo is added to the current directory structure.
2. Compile the project locally
fun buildto compile and build the project:
3. Run the project locally
fun local start to run the FUN function locally.
fun local start demo-springboot
4. Perform local single-step debugging
fun local start to perform local single-step debugging on the function.
Considering our audience, we will not use plug-ins for debugging here.
5. Package and deploy the project
fun deploy --use-rosto deploy the project through ROS.
fun package --oss-bucket fun-local-test fun deploy --use-ros --stack-name staging
--oss-bucket name indicates the name of an OSS bucket that you can read and write.
--stack-name indicates the environment where the project is deployed. You can create multiple
development environments by setting different names for them, such as test, staging,
After the test is completed, you can log on to the ROS console to delete the staging resource stack just created with a single click. After the deletion, all resources contained in this stack will also be deleted.