mybatis (entry-level project)

 

Framework construction: (two java classes, two xml configuration files)

1. Import the jar package, log debug file and database parameter file

 

2. Create a persistent class (the same class as the column value of the database)

An extension of the user class:

 

 

userQueryVo is a wrapper class for UserCustom:

 

3. Create a mapper and the corresponding .java file

UserMapper.java file:

 

userMapper.xml

 

 

 

The key value can be returned when inserting:

Note that the writing in mapper should correspond to the interface

4. Create a core xml configuration file (configuration environment configuration mapper)

 

 

5. Create a test class (get sqlsession for operation)

Organize the idea map: (important!)

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325060885&siteId=291194637