In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you how to deploy Spring PetClinic to the functional computing platform. I believe most people have not learned this skill. In order to let you learn, I have summarized the following contents. Without saying much, let's read on.
Concept:
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 you deploy Region in China, you need to file 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 by your AccountID. If you are in a foreign country, you can dispense with the filing process. Please check out more RDS-MySQL cloud services created by the reference template that use the cheapest postpaid instance. The fee is about ¥0.236 / hour. You need to make sure that the account has a balance of RMB 100 before use, and it is recommended to delete the application through the ROS console after the trial is completed, so as to avoid exceeding the expected cost. 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 customize the personalized language execution environment (such as Golang, Lua, Ruby) and small versions of various languages (such as Python3.7, Nodejs12) as you like, create your own custom Runtime existing Web applications or develop Web projects based on traditional Web projects without any modification, and you can migrate 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.
DockerFuncraft
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
These are the details of how to deploy Spring PetClinic to the function computing platform, and do you have anything to gain after reading it? If you want to know more about it, you are welcome to follow the industry information!
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.