In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to migrate Spring Boot to function computing", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to migrate Spring Boot to function calculation"!
First of all, we introduce several important concepts that appear in this article:
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 techniques described in this article require 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 under 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-ycurrent folder is not a fun project.Generating template.yml...Generate Fun project satisfied = Fun will use 'fun deploy' to deploy your application to Function Compute! = using region: cn-qingdaousing accountId: * 3743using accessKeyId: * Ptgkusing timeout: 60Collecting 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 successservice Spring-Boot deploy successDetect 'DomainName:Auto' of custom domain' Domain'Request a new temporary domain... The assigned temporary domain is 15639196techXXX.test.functioncompute.com Only FC resources changes will be displayed Only FC resources changes will be displayed 2020-04-10 15:19:56, limited by 1000 per day.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.
Summary
This article describes how to deploy Spring Boot applications to function calculations. 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.
At this point, I believe you have a deeper understanding of "how to migrate Spring Boot to function calculation". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.