To do any framework integration, we must first introduce related dependencies.
When there is no Spring, Mybatis can be used normally (write main configuration file, write tool class, write tool class and create table after writing tool class, write entity object, write dao interface, write Mapper configuration file registration, write business)
Access to the database refers to CRUD
Without sqlsession, you can't get dao and you can't complete database operations
The above is pseudo code
The data source is a connection pool
Spring integrates Mybatis programming Dao layer development
Import dependencies first, then write Spring configuration
4. Create an entity class
The implementation of the interface is done in Mybatis through the mapper configuration file.
It turns out that we have to register in the main configuration file when we finish writing the mapper.
The array uses the injection of the array tag
Here getMapper is the interface of userDao, which should be mapped to its implementation class so that the method can be called.