In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how SpringBoot connects to MySQL to get data and writes the back-end interface. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
1. New project
two。 Add dependency
Mysql mysql-connector-java 8.0.20 org.springframework spring-jdbc 5.3.8 org.springframework spring-tx 5.3.8 org.springframework spring-aop 5.3.8
Create DriverManagerDataSource and JdbcTemplate objects in 3.spring Container 3.1 method of loading spring container in springboot 1. Create spring container file under resource
Resource-> new---- > Directory---- > new Directory (application)
two。 Define a normal class and add the above comments to the class to automatically load the spring container after springboot startup
4. Create an object class and control the class Book
Note the @ Data annotation here, which is a part of lombok and is mainly used to generate get,set methods automatically at compile time, so there is no need for us to write get set methods manually in this class, which reduces our workload. It is very convenient and highly recommended.
BookDao
TestController
Application.properties
5. Start the MySQL database
You can refer to the previous article
Install MySQL8.0 and visualize the operation in Navicat
6. Run the test
As shown in the following figure, the operation is successful
Enter it in the browser to see if it is successful.
Description:
8080 and springboot reference application.properties
GetbookList is customized in RequestMapping in TestController
At this point, the SpringBoot back-end interface is written.
This is the end of the article on "how to connect SpringBoot to MySQL to obtain data and write back-end interface". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.