In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to lightly migrate SpringBoot applications to the cloud through the Serverless application console. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Spring Boot is a framework provided by the Pivotal team to simplify the initial building and development of new Spring applications. The framework uses a specific way of configuration, so that developers no longer need to define a templated configuration, so the Spring Boot framework has become a very popular framework.
Today, you can migrate your SpringBoot applications to the cloud by making extremely simple code modifications through the Serverless application console.
Functional advantage
Low transformation cost: Serverless components automatically help users complete the cloud adaptation conversion on the framework. Users only need to focus on the business core code and make few code modifications to complete cloud deployment.
Application-level resource display and management: after successful deployment, users can easily view and manage the created cloud resources through the Serverless application console without the need for multiple page switching to achieve centralized management of multiple resources.
Continuous code update: continuous build is supported, and redeployment can be triggered automatically when the content uploaded to the folder is updated.
Application-level monitoring chart: provides the monitoring capability at the application level. Users can see not only the number of calls and errors of each resource, but also the monitoring indicators at the application level, which is convenient for operation and maintenance.
Follow these tutorial steps to quickly experience the framework migration:
Prerequisite for deployment: the account has activated Serverless Framework: https://console.cloud.tencent.com/sls and Coding DevOps: https://console.cloud.tencent.com/coding services. Log in to the console and activate the service automatically for you. There is no charge for activating the process.
Create applications based on templates
Go to the Serverless application console and click "New Application" to enter the application creation page.
Enter your application name, select * * create template * *, and select Spring Boot frame.
Click "create", and the Serverless console will automatically start to deploy the application for you. After the deployment is completed, you can go to the application details page to view the created cloud resources, monitoring logs, deployment records and other information. You can also modify the configuration and redeploy on the "Development and deployment" page.
Import an existing project
Code modification: if you deploy with your own SpringBoot project code, you need to make the following modifications
Add the dependency of Tencent Cloud function (version 0.0.3) and fastjson in the project pom.xml (if you have a useful version of your project, you can not modify it; if not, please rely on the latest version).
Com.tencentcloudapi scf-java-events 0.0.3 com.alibaba fastjson 1.2.73
Add an execution method entry under any directory of the src/main/java in the root directory of the project, for example, create a new MyHandler.java under the src/main/java/example directory
Package example;import com.qcloud.scf.runtime.AbstractSpringHandler;public class MyHandler extends AbstractSpringHandler {@ Override public void startApp () {System.out.println ("start app"); / / modified to the entry main function of the springboot project, for example: the entry is the main function DemoApplication.main under DemoApplication class (new String [] {""});}}
Create a jar deployment package with Maven or a zip deployment package with Gradle.
All dependent packages of the project need to be packaged together. For example, if you use Maven, it is recommended to package with maven-shade-plugin, and modify the plugin in pom.xml:
Org.apache.maven.plugins maven-shade-plugin 3.1.1 false package shade
Description of cloud function on Maven deployment package: click here to view the description of cloud function on Gradle deployment package: click here to view
Modify the projectJarName configuration in the serverless.yml file to the packaged .jar / .zip file name, and the .jar/.zip file needs to be placed at the same level as serverless.yml.
For example, if a code.jar file is generated after being packaged with Maven, projectJarName is code.jar
Modify the handler configuration of functionConfig in the serverless.yml file in the format [package]. [class]:: mainHandler where package is used for more layers. Connect.
For example, if the newly created MyHandler.java is placed in src/main/java/example, handler is example.MyHandler::mainHandler
Go to the Serverless application console and click "New Application" to enter the application creation page.
Enter your application name, select * * Import existing Project * *, and select Spring Boot App to import your existing project directly. Select "Local upload" code upload method, upload Maven to create jar deployment package or use Gradle to create zip deployment package.
Click "create", and the Serverless console will automatically start to deploy the application for you. After the deployment is completed, you can go to the application details page to view the created cloud resources, monitoring logs, deployment records and other information. You can also modify the configuration and redeploy on the "Development and deployment" page.
Management and application
After the application is created, you can view the project details on the application details page, which mainly supports the following management functions.
1. Resource management
On the "Resource list" page, you can view the cloud resources created for you by the current application, and view the basic configuration information.
two。 Development and deployment
At the top of the application details page, click "Development deployment" to easily modify the configuration of the application and upload it for secondary deployment. Currently, SpringBoot only supports local upload.
At the same time, you can also modify the application configuration information on this page and click "Save" to complete the redeployment.
3. Application monitoring
On the * * Application Monitoring * * page, you can view the basic information, project request times, project error statistics and other monitoring metrics output after project deployment, which makes it easy for you to manage and maintain the project.
4. Deployment log
On the "deployment Log" page, you can see the deployment log of "deploy through console" or "automatically triggered", as well as the deployment result.
At this point, you only need extremely simple code modification to complete the operation of migrating your Spring Boot application to Serverless, and you can monitor and manage the application, develop continuously, and enjoy the many advantages brought by Serverless.
The above content is how to migrate SpringBoot applications to the cloud through the Serverless application console. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.