@Bean(name = "dbzyqsV102SqlSessionFactory") // @Qualifier表示查找Spring容器中名字为blogDataSource的对象 public SqlSessionFactory dbzyqsV102SqlSessionFactory(@Qualifier("dbzyqsV102DataSource") DataSource datasource) throws Exception { MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean(); mybatisSqlSessionFactoryBean.setDataSource(datasource); MybatisConfiguration configuration = new MybatisConfiguration(); // 关闭驼峰 configuration.setMapUnderscoreToCamelCase(false); configuration.addInterceptor(new PaginationInterceptor()); if ("uat".equals(active)) { configuration.setLogImpl(org.apache.ibatis.logging.stdout.StdOutImpl.class); } mybatisSqlSessionFactoryBean.setConfiguration(configuration); Interceptor interceptor = new PageInterceptor(); Properties properties = new Properties(); properties.setProperty("helperDialect", "mysql"); properties.setProperty("offsetAsPageNum", "true"); properties.setProperty("rowBoundsWithCount", "true"); properties.setProperty("reasonable", "true"); properties.setProperty("supportMethodsArguments", "true"); properties.setProperty("params", "pageNum=pageNumKey;pageSize=pageSizeKey;"); interceptor.setProperties(properties); mybatisSqlSessionFactoryBean.setPlugins(new Interceptor[]{interceptor}); mybatisSqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/dbzyqsV102/*.xml")); return mybatisSqlSessionFactoryBean.getObject(); }
标签:mybatisSqlSessionFactoryBean,打印,setProperty,mybatis,new,日志,configuration,true,pr From: https://www.cnblogs.com/deepalley/p/18332699