In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to quickly deploy Spring PetClinic to the function computing platform, which may not be well understood by many people. 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.
Brief introduction
First of all, we will introduce some of the 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.
Funcraft:Funcraft is a tool for supporting the deployment of Serverless applications, 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.
Spring-petclinic: PetClinic is a sample project that combines Spring Boot, Spring MVC, and Spring Data to learn from the classic case of Spring Boot.
The Spring framework is integrated by some small and beautiful Java frameworks in a loosely coupled manner. These Java frameworks can be used independently or integrated to build many different types of industrial applications. The PetClinic sample application is intended to demonstrate how to use the Spring application framework to build simple and powerful database-oriented applications. It demonstrates the use of the core functions of Spring.
Web presentation layer using inversion of control and MVC, JavaBeans-based application configuration, database access through JDBC,Hibernate or JPA, application monitoring based on JMX declarative transaction management, Spring framework that uses AOP data validation to support but does not rely on the presentation layer provides a large number of useful infrastructure to simplify application development.
The template uses functional computed Custom runtime and RDS-MySQL cloud services as the running environment for Spring Boot applications. With the help of the resource orchestration service (ROS), the template automatically creates VPC, VSwitch, SecurityGroup, RDS and functions bound to HTTP Trigger, as well as custom domain names bound to HTTP functions, and automatically configures these services to achieve instant online and out-of-the-box use.
Note:
You need to provide a domain name (second-level domain name is supported). If the domain name is deployed in the domestic Region, you need to register the domain name in Aliyun, and then point the CNAME record of the domain name to 12345.cn-shanghai.fc.aliyuncs.com, of which 12345 is replaced with your AccountID. If you are in a foreign country, Region can be exempted from the filing process. Please see more references.
The cheapest postpaid instance is selected for the RDS-MySQL cloud service created by the template, and the fee is about ¥0.236 / hour. You need to ensure that the account has a balance of RMB 100 before using it. After the trial is completed, it is recommended to delete the application through the ROS console to avoid exceeding the expected fee.
Quick start
Now we quickly deploy Spring PetClinic to the function computing platform with the help of Tencent App Center of function computing.
Open the details page of the function calculation Spring PetClinic application. If you have not activated the function computing service, you may need to activate the service first. The service is free of charge. In addition, there is a monthly free quota for function calculation, and there is no fee for the trial service.
Scroll to the bottom of the Spring PetClinic application details page and click the "deploy now" button.
Enter the application name and domain name, in which the domain name needs to set the CNAME record of DNS, and then click the "deploy" button.
Wait a moment, and after the deployment is successful, copy the URL URL.
Open the URL copied above in the browser
working principle
In this example, we intend to migrate the Petclinic project using the Custom runtime calculated by the function. As the name implies, Custom Runtime is a custom execution environment, and users can achieve the following goals based on Custom Runtime:
You can create your own custom Runtime with customized language execution environments (such as Golang, Lua, Ruby) and small versions of various languages (such as Python3.7, Nodejs12) as you like.
Existing Web applications or Web projects based on traditional development basically do not need to do any modification, you can transfer the project to the function computing platform with one click.
The architecture of the application is as follows:
Customized development dependency tools
This project is developed under MacOS, the tools involved are platform-independent, and should also be applicable to Linux and Windows desktop systems. Before starting this example, make sure that the following tools are installed correctly, updated to the latest version, and configured correctly.
Docker
Funcraft
The Fun tool relies on docker to simulate the local environment.
For MacOS users, you can use homebrew to install:
Brew cask install dockerbrew tap vangie/formulabrew install fun
For Windows and Linux user installation, please refer to:
Https://github.com/aliyun/fun/blob/master/docs/usage/installation.md
After installation, remember to initialize the configuration by executing fun config first.
Note that if you have already installed funcraft, make sure that the funcraft version is above 3.2.1.
$fun-- version3.2.1 initializes git clone https://github.com/awesome-fc/spring-petclinic-for-serverlesscd spring-petclinic-for-serverless compilation package mvn package-Dmaven.test.skip=true runs locally MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_DBNAME=petclinic MYSQL_USER=root MYSQL_PASSWORD=. / bootstrap
Start the local MySQL database before running the above command, and replace the value of the above MYSQL_* with the configuration of your local MySQL database.
Deploy make deploy
In order to get a better development experience, it is recommended to install Aliyun Serverless VSCode Extension
After reading the above, do you have any further understanding of how to quickly deploy Spring PetClinic to the function computing platform? 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.