本文整理汇总了Java中org.mybatis.spring.SqlSessionFactoryBean.setPlugins方法的典型用法代码示例。如果您正苦于以下问题:Java SqlSessionFactoryBean.setPlugins方法的具体用法?Java SqlSessionFactoryBean.setPlugins怎么用?Java SqlSessionFactoryBean.setPlugins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mybatis.spring.SqlSessionFactoryBean
的用法示例。
在下文中一共展示了SqlSessionFactoryBean.setPlugins方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: businessSqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
@Primary
public SqlSessionFactory businessSqlSessionFactory(@Qualifier("businessDataSource") DruidDataSource businessDataSource) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(businessDataSource);
//mybatis分页
PageHelper pageHelper = new PageHelper();
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "true");
props.setProperty("returnPageInfo", "check");
props.setProperty("params", "count=countSql");
pageHelper.setProperties(props);
//添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(MAPPERXML_LOCATION));
return sqlSessionFactoryBean.getObject();
}
示例2: sqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource());
//mybatis分页
PageHelper pageHelper = new PageHelper();
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "true");
props.setProperty("returnPageInfo", "check");
props.setProperty("params", "count=countSql");
pageHelper.setProperties(props); //添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/me/caixin/dao/mapping/**/*.xml"));
return sqlSessionFactoryBean.getObject();
}
示例3: sqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource());
//mybatis分页
PageHelper pageHelper = new PageHelper();
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "true");
props.setProperty("returnPageInfo", "check");
props.setProperty("params", "count=countSql");
pageHelper.setProperties(props); //添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:org/xxpay/shop/dao/mapper/*.xml"));
return sqlSessionFactoryBean.getObject();
}
示例4: sqlSessionFactoryBean
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public SqlSessionFactoryBean sqlSessionFactoryBean(
DataSource dataSource,
ApplicationContext applicationContext) throws IOException {
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
// 마이바티스가 사용한 DataSource를 등록
factoryBean.setDataSource(dataSource);
// 마이바티스 설정파일 위치 설정
factoryBean.setConfigLocation(applicationContext.getResource("classpath:mybatis-config.xml"));
factoryBean.setMapperLocations(applicationContext.getResources("classpath:net/andromedarabbit/persistence/mybatis/**/*.xml"));
factoryBean.setPlugins(new Interceptor[]{
new PaginationInterceptor(),
new PaginationResultSetHandlerInterceptor()
});
return factoryBean;
}
示例5: sqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource());
//mybatis分页
PageHelper pageHelper = new PageHelper();
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "true");
props.setProperty("returnPageInfo", "check");
props.setProperty("params", "count=countSql");
pageHelper.setProperties(props); //添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:org/xxpay/dal/dao/mapper/*.xml"));
return sqlSessionFactoryBean.getObject();
}
示例6: read2SqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
/**
* SqlSessionFactory配置
*
* @return
* @throws Exception
*/
@Bean(name = "read2SqlSessionFactory")
public SqlSessionFactory read2SqlSessionFactory(
@Qualifier("read2DataSource") DataSource dataSource
) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
// 配置mapper文件位置
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(read2MapperLocations));
//配置分页插件
PageHelper pageHelper = new PageHelper();
Properties properties = new Properties();
properties.setProperty("reasonable", "true");
properties.setProperty("supportMethodsArguments", "true");
properties.setProperty("returnPageInfo", "check");
properties.setProperty("params", "count=countSql");
pageHelper.setProperties(properties);
//设置插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
return sqlSessionFactoryBean.getObject();
}
示例7: read1SqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
/**
* SqlSessionFactory配置
*
* @return
* @throws Exception
*/
@Bean(name = "read1SqlSessionFactory")
public SqlSessionFactory read1SqlSessionFactory(
@Qualifier("read1DataSource") DataSource dataSource
) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
// 配置mapper文件位置
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(read1MapperLocations));
//配置分页插件
PageHelper pageHelper = new PageHelper();
Properties properties = new Properties();
properties.setProperty("reasonable", "true");
properties.setProperty("supportMethodsArguments", "true");
properties.setProperty("returnPageInfo", "check");
properties.setProperty("params", "count=countSql");
pageHelper.setProperties(properties);
//设置插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
return sqlSessionFactoryBean.getObject();
}
示例8: masterSqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
/**
* SqlSessionFactory配置
*
* @return
* @throws Exception
*/
@Bean(name = "masterSqlSessionFactory")
@Primary
public SqlSessionFactory masterSqlSessionFactory(
@Qualifier("masterDataSource") DataSource dataSource
) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
// 配置mapper文件位置
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(masterMapperLocations));
//配置分页插件
PageHelper pageHelper = new PageHelper();
Properties properties = new Properties();
properties.setProperty("reasonable", "true");
properties.setProperty("supportMethodsArguments", "true");
properties.setProperty("returnPageInfo", "check");
properties.setProperty("params", "count=countSql");
pageHelper.setProperties(properties);
//设置插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
return sqlSessionFactoryBean.getObject();
}
示例9: clusterSqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
/**
* SqlSessionFactory配置
*
* @return
* @throws Exception
*/
@Bean(name = "clusterSqlSessionFactory")
public SqlSessionFactory clusterSqlSessionFactory(
@Qualifier("clusterDataSource") DataSource dataSource
) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//配置mapper文件位置
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(clusterMapperLocations));
//配置分页插件
PageHelper pageHelper = new PageHelper();
Properties properties = new Properties();
properties.setProperty("reasonable", "true");
properties.setProperty("supportMethodsArguments", "true");
properties.setProperty("returnPageInfo", "check");
properties.setProperty("params", "count=countSql");
pageHelper.setProperties(properties);
//设置插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
return sqlSessionFactoryBean.getObject();
}
示例10: cluster1SqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
/**
* SqlSessionFactory配置
*
* @return
* @throws Exception
*/
@Bean(name = "cluster1SqlSessionFactory")
public SqlSessionFactory cluster1SqlSessionFactory(
@Qualifier("cluster1DataSource") DataSource dataSource
) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//配置mapper文件位置
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(cluster1MapperLocations));
//配置分页插件
PageHelper pageHelper = new PageHelper();
Properties properties = new Properties();
properties.setProperty("reasonable", "true");
properties.setProperty("supportMethodsArguments", "true");
properties.setProperty("returnPageInfo", "check");
properties.setProperty("params", "count=countSql");
pageHelper.setProperties(properties);
//设置插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
return sqlSessionFactoryBean.getObject();
}
示例11: sqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean("sqlSessionFactory")
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource());
sessionFactory.setConfiguration(configuration());
sessionFactory.setTypeAliasesPackage(entityBasePackage);
sessionFactory.setTypeAliasesSuperType(AbstractEntity.class);
sessionFactory.setMapperLocations(getResources(mapperResources));
OffsetLimitInterceptor offserInterceptor = new OffsetLimitInterceptor();
offserInterceptor.setDialect(new MySQLDialect());
MapperInterceptor mapperInterceptor = new MapperInterceptor();
Properties properties = new Properties();
properties.setProperty("mappers", mappers);
properties.setProperty("IDENTITY", dialect);
mapperInterceptor.setProperties(properties);
sessionFactory.setPlugins(new Interceptor[] { offserInterceptor ,mapperInterceptor});
return sessionFactory.getObject();
}
示例12: sqlSessionFactoryBean
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public static SqlSessionFactory sqlSessionFactoryBean(DataSource dataSource) throws Exception {
SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
factory.setDataSource(dataSource);
factory.setTypeAliasesPackage(MODEL_PACKAGE);
//配置分页插件,详情请查阅官方文档
PageHelper pageHelper = new PageHelper();
Properties properties = new Properties();
properties.setProperty("pageSizeZero", "true");//分页尺寸为0时查询所有纪录不再执行分页
properties.setProperty("reasonable", "true");//页码<=0 查询第一页,页码>=总页数查询最后一页
properties.setProperty("supportMethodsArguments", "true");//支持通过 Mapper 接口参数来传递分页参数
pageHelper.setProperties(properties);
//添加插件
factory.setPlugins(new Interceptor[]{pageHelper});
//添加XML目录
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
factory.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
return factory.getObject();
}
示例13: businessSqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
@Primary
public SqlSessionFactory businessSqlSessionFactory(@Qualifier("businessDataSource") DruidDataSource businessDataSource) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(businessDataSource);
//mybatis分页
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "true");
props.setProperty("returnPageInfo", "check");
props.setProperty("params", "count=countSql");
PageHelper pageHelper = new PageHelper();
pageHelper.setProperties(props);
//添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(MAPPERXML_LOCATION));
return sqlSessionFactoryBean.getObject();
}
示例14: sqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public SqlSessionFactory sqlSessionFactory( @Autowired DynamicDataSource dynamicDataSource ) {
try {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dynamicDataSource);
sessionFactory.setTypeAliasesPackage(this.typeAliasesPackage);
sessionFactory.setMapperLocations( new PathMatchingResourcePatternResolver().getResources(mapperLocations) );
sessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver().getResource(configLocation));
PageHelper pageHelper = new PageHelper();
Properties props = new Properties();
props.setProperty("reasonable", "false");
props.setProperty("supportMethodsArguments", "true");
props.setProperty("returnPageInfo", "check");
props.setProperty("params", "count=countSql");
pageHelper.setProperties(props);
sessionFactory.setPlugins(new Interceptor[] { pageHelper });
return sessionFactory.getObject();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例15: sqlSessionFactory
import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean(name = "sqlSessionFactory")
@ConditionalOnMissingBean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
factory.setDataSource(dataSource);
if (StringUtils.hasText(this.properties.getConfig())) {
factory.setConfigLocation(
this.resourceLoader.getResource(this.properties.getConfig()));
} else {
if (this.interceptors != null && this.interceptors.length > 0) {
factory.setPlugins(this.interceptors);
}
factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
factory.setMapperLocations(this.properties.getMapperLocations());
}
return factory.getObject();
}