@Configuration
@ConditionalOnBean(DataSource.class)
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
@MapperScan("com.xxx.xxxxx.mapper")
public class MybatisPlusConfig {
//分页插件
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
/**
* 自定义主键生成策略
*
* @return
*/
@Bean
public IdentifierGenerator idGenerator() {
return new CustomIdGenerator();
}
}
在给配置类中 注入的分页拦截器不起作用,
当把该bean对象配置到启动类当中 就能够发挥分页作用,自己没搞懂求大神指教
@SpringBootApplication
@MapperScan("com.xxxx.xxxxx.mapper")
public class ExplorationDataApplication {
public static void main(String[] args) {
SpringApplication.run(ExplorationDataApplication.class, args);
}
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
}