Description: The data can be found, and the list returned to the front end also has data, but the total is always 0 and cannot be paged
After checking the information, I saw many friends talking about configuration problems, and then flipped through the code, I lost it! I forgot to write the configuration class. To use the paging function provided by MybatisPlus, you need to configure the paging plugin!
The configuration is as follows (the configuration method of the new version of the plug-in, the configuration method of the old version can be checked on the official website):
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
The plugin needs to use the mybatis-plus-extension dependency, but generally it does not need to be imported. The mybatis-plus-boot-starter dependency we introduced when inheriting MybatisPlus will pass the import:
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>3.4.3</version>
</dependency>