@Configuration
public class MybatisPlusConfig {
@Bean(name = "globalConfig")
public GlobalConfig globalConfig(@Qualifier("myBatisPlusMetaObjectHandler") MyBatisPlusMetaObjectHandler metaObjectHandler) {
GlobalConfig globalConfig = new GlobalConfig();
(metaObjectHandler);
return globalConfig;
}
@Bean
@Primary
public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSource") DataSource dataSource,
@Qualifier("globalConfig") GlobalConfig globalConfig) throws Exception {
MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
(dataSource);
//添加分页功能================================================================================================
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
(new PaginationInnerInterceptor());
(interceptor);
(globalConfig);
return ();
}
@Bean
@Primary
public SqlSessionTemplate sqlSessionTemplate(@Qualifier("sqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
@Bean
@Primary
public DataSourceTransactionManager dataSourceTransactionManager(@Qualifier("dataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}