mybatis-plus相关配置
mybatis-plus:
mapper-locations: classpath:mapper/*.xml #配置xml类路径(resource下的mapper包下所有的xml)
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启日志
map-underscore-to-camel-case: true #开启驼峰命名
type-aliases-package: com.minzhen.blog.entity #设置MyBaits 别名包扫描路径,通过该属性可以给包中的类注册别名,注册后在 Mapper 对应的 XML 文件中可以 直接使用类名,而不用使用全限定的类名(即 XML 中调用的时候不用包含包名)
配置分页
@Configuration
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
}
业务:
IPage pages = new Page(1,5);//当前页,每页大小
articleDao.selectPage(page,null);