| | |
| | | |
| | | import com.baomidou.mybatisplus.plugins.PaginationInterceptor; |
| | | import com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean; |
| | | import org.apache.ibatis.plugin.Interceptor; |
| | | import org.apache.ibatis.session.SqlSessionFactory; |
| | | import org.mybatis.spring.SqlSessionFactoryBean; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | |
| | | public class SecondaryDataSourceConfig { |
| | | |
| | | @Bean(name = "secondarySqlSessionFactory") |
| | | public MybatisSqlSessionFactoryBean secondarySqlSessionFactory(@Qualifier("slaveDataSource") DataSource dataSource) throws Exception { |
| | | public MybatisSqlSessionFactoryBean secondarySqlSessionFactory(@Qualifier("slaveDataSource") DataSource dataSource, PaginationInterceptor paginationInterceptor) throws Exception { |
| | | MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean(); |
| | | sessionFactory.setDataSource(dataSource); |
| | | // 设置MyBatis的Mapper XML文件路径 |
| | | sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver() |
| | | .getResources("classpath:mapper/nc/*.xml")); |
| | | Interceptor[] interceptors = new Interceptor[] { paginationInterceptor }; |
| | | sessionFactory.setPlugins(interceptors); |
| | | |
| | | return sessionFactory; |
| | | } |
| | | |