Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using spring boot tools to integrate mysql method

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly tells you about the use of spring boot tools to integrate mysql methods. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here. Let's go straight to the topic. I hope that using spring boot tools to integrate mysql methods can bring you some practical help.

I. 4.21 accumulated knowledge points

@ Controller identifies a Spring class as a Spring MVC controller processor

@ RestController: a combination of @ Controller and @ ResponseBody that combines the two annotations.

@ Transactional: the class or method marked with this annotation indicates that all the methods in this class or the transaction of this method is handled by spring to ensure the atomicity of the transaction. I don't know if you can understand this, that is, the database operation is faced with in the method. If it fails, spring is responsible for the rollback operation and successfully commits the operation.

Application.JAVA files cannot be placed directly under the main/java folder. You must build a package to put it in. If there is no way to enter it, you will report * * WARNING * *: Your ApplicationContext is unlikely to start due to a @ ComponentScan of the default package.

Use spring boot to connect to the database

1. Introduce JPA and MySql and dependencies into maven

two。 Create an entity class

3. Entity persistence: defines that the interface inherits the JpaRepository interface.

Repository

| |

CrudRepository: add, delete, modify and check

| |

PaginAndSortingRepository: provides paging and sorting capabilities

| |

JpaRepository

Jpa also provides custom declaration method rules, using the keywords findBy, readBy, getBy as prefixes, depending on the attribute fields of the entity class (uppercase), and relying on the SQL query keyword to form a query method.

Eg:findByIdAndName (Long id,String name)

Use spring boot tools to integrate the mysql method to tell you here, for other related issues you want to know can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report