In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Today, I will talk to you about how to migrate Spring Boot to function calculation, many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
First of all, we will introduce several more important concepts that have emerged:
Function computing (Function Compute): function computing is an event-driven service. Through function calculation, users do not need to manage the operation of the server, but only need to write code and upload. The function calculation prepares the computing resources and runs the user code in an elastic way, while the user only needs to pay according to the resources consumed by the actual code. Function to calculate more information.
Fun: Fun is a tool for supporting Serverless application deployment, which can help you easily manage resources such as function computing, API gateways, log services, and so on. It assists you in developing, building, and deploying operations through a resource configuration file (template.yml). More documentation references for Fun.
Note: the technique introduced requires Fun version 3.6.3 or greater.
Background information
Spring Boot was developed by the Pivotal team in 2013 and released the first version of the new open source lightweight framework in April 2014. Based on Spring4.0 design, it not only inherits the excellent features of Spring framework, but also further simplifies the whole construction and development process of Spring application by simplifying configuration. In addition, Spring Boot solves the problems of version conflicts of dependent packages and instability of references by integrating a large number of frameworks.
Step 1: environmental preparation
In the method described in this article, you don't need to install Docker, just install Fun. The easiest way is to download executable binaries directly.
Install Fun to this machine. See the installation documentation for details.
Execute fun-- version to check that the installation is successful.
Step 2: migration process
Create a Spring Boot project, see Spring Quickstart Guide for details, skip this step if you have a Spring Boot project.
Go to the sample project you just created or your project.
Cd
Run the project locally.
Running projects on MacOS and Linux platforms:
. / mvnw spring-boot:run
The windows platform runs the project:
Mvnw spring-boot:run
Execute the mvn package command package in the root directory of the project, and the compilation output is similar to the following.
$mvn package [INFO] Scanning for projects... [INFO] [INFO]--
< com.example:Spring-Boot >-[INFO] Building Spring-Boot 0.0.1-SNAPSHOT [INFO]-[jar]-[INFO] [INFO]- -maven-resources-plugin:3.1.0:resources (default-resources) @ Spring-Boot-- [INFO] [INFO] Results: [INFO] [INFO] Tests run: 1, Failures: 0, Errors: 0 Skipped: 0 [INFO] [INFO] [INFO]-maven-jar-plugin:3.1.2:jar (default-jar) @ Spring-Boot--[INFO] Building jar: / Users/txd123/Desktop/Spring-Boot/target/Spring-Boot-0.0.1-SNAPSHOT.jar [INFO] [INFO]-spring-boot-maven-plugin:2.2.6.RELEASE:repackage (repackage) @ Spring-Boot- [INFO ] Replacing main artifact with repackaged archive [INFO]-[INFO] BUILD SUCCESS [INFO]- -[INFO] Total time: 38.850 s [INFO] Finished at: 2020-03-31T15:09:34+08:00 [INFO]- -
Only one command is needed to deploy the project to the function calculation: fun deploy-y focus fun will automatically enter the deployment process.
$fun deploy-y current folder is not a fun project. Generating template.yml... Generate Fun project successfully! = Fun will use 'fun deploy' to deploy your application to Function Compute! = using region: cn-qingdao using accountId: * 3743 using accessKeyId: * Ptgk using timeout: 60 Collecting your services information, in order to caculate devlopment changes... Resources Changes (Beta version! Only FC resources changes will be displayed): trigger httpTrigger deploy success function Spring-Boot deploy success service Spring-Boot deploy success Detect 'DomainName:Auto' of custom domain' Domain' Request a new temporary domain. The assigned temporary domain is 15639196per day XXX.test.functioncompute.com at 2020-04-10 15:19:56, limited by 1000. Waiting for custom domain Domain to be deployed... Custom domain Domain deploy success
After the deployment is completed, you can see that a temporary domain name has been generated for you according to the log of the successful deployment. You can directly access the newly deployed application through this temporary domain name.
Note: the temporary domain name is only used for demonstration and development, and it is time-limited. If it is used for production, please bind the domain name that has been licensed by Aliyun. For more information, please see binding Custom Domain name.
Compared with traditional deployment methods, you can deploy traditional Spring Boot applications to the remote end with one click for direct production. While skipping steps such as buying a machine, it also has the features of flexible scaling, pay-per-use and free operation and maintenance.
After reading the above, do you have any further understanding of how to migrate Spring Boot to function computation? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.