mybatis javaConfig实现
@Bean public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { SqlSessionFactoryBean fb = new SqlSessionFactoryBean(); fb.setDataSource(dataSource); fb.setMapperLocations( new PathMatchingResourcePatternResolver().getResources(env.getProperty("mybatis.mapper-locations"))); PageHelper pageHelper = new PageHelper(); Properties props = new Properties(); props.setProperty("reasonable", "true"); props.setProperty("supportMethodsArguments", "true"); props.setProperty("returnPageInfo", "check"); props.setProperty("params", "count=countSql"); pageHelper.setProperties(props); fb.setPlugins(new Interceptor[] { pageHelper }); //mybatis的Configuration org.apache.ibatis.session.Configuration cfg = new org.apache.ibatis.session.Configuration(); cfg.setCacheEnabled(false); fb.setConfiguration(cfg); return fb.getObject(); }