1. 使用javaBean配置方式
在javaBean的方式中,我们使用SqlSessionFactoryBean类的setPlugins来加载plugins,具体的配置代码如下:
@Bean public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource, PageHelper pageHelper) throws IOException { SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); bean.setDataSource(dataSource); bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml")); bean.setPlugins(new Interceptor[]{pageHelper}); return bean; } @Bean public PageHelper pageHelper() { PageHelper pageHelper = new PageHelper(); Properties properties = new Properties(); properties.setProperty("dialect