1. Write a configuration class
@Configuration
Indicate it is a configuration class, spring will scan and load
@EnableTransactionManagement
Here to indicate that the transaction annotation is turned on
@MapperScan("")
The mapper that needs to be scanned is also indicated here
- In this case, there is no need to indicate these annotations in the main startup class
@Configuration
@EnableTransactionManagement
@MapperScan("")
public class MybatisConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setOverflow(true);
paginationInterceptor.setLimit(1000);
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
return paginationInterceptor;
}
}
2. Related configuration
mybatis-plus:
Configuration in the configuration file
mapper-locations:
path
global-config.db-config.id-type
Self-increment mode of database
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto
3. To be updated