[Mybatis-plus] Tips for using mybatis-plus in springboot

1. First add pom.xml dependency

 <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.1</version>
        </dependency>

2. Add data source information, and add the location information of the mapper

Insert picture description here


Insert picture description here

3. Add the entity class User.java, show that the specified mybatis-plus queries the user table in the database, and does not query the book field

Insert picture description here


4. Write the UserTestMapper interface, mainly

extends BaseMapper<User>

Crud can be realized automatically, eliminating various operations in mybatis

Insert picture description here

5. Write the implementation class interface UserTestService.java, realize

extends IService<User>
Insert picture description here

6. Implement UserTestService interface, UserTestServiceImpl.java, use

extends ServiceImpl<UserTestMapper, User>
        implements UserTestService

UserTestServiceImpl can automatically implement various addition, deletion, and modification operations

Insert picture description here

The automatic realization method is as follows:

Insert picture description here


7. Whether the test method is realized

Insert picture description here


Realization result:

Insert picture description here