當前位置: 首頁>>代碼示例>>Java>>正文


Java Interceptor類代碼示例

本文整理匯總了Java中org.apache.ibatis.plugin.Interceptor的典型用法代碼示例。如果您正苦於以下問題:Java Interceptor類的具體用法?Java Interceptor怎麽用?Java Interceptor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Interceptor類屬於org.apache.ibatis.plugin包,在下文中一共展示了Interceptor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: businessSqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:DomKing,項目名稱:busi-support,代碼行數:21,代碼來源:BusinessDatabaseConfig.java

示例2: sqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:jmdhappy,項目名稱:xxpay-master,代碼行數:19,代碼來源:DruidDataSourceConfig.java

示例3: sqlSessionFactoryBean

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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;
}
 
開發者ID:andromedarabbit,項目名稱:mybatis-pagination,代碼行數:22,代碼來源:MyBatisConfig.java

示例4: sqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:cairenjie1985,項目名稱:springBoot-demo,代碼行數:18,代碼來源:MyBatisAutoConfiguration.java

示例5: sqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:ywtnhm,項目名稱:pay-xxpay-master,代碼行數:19,代碼來源:DruidDataSourceConfig.java

示例6: createSqlSessionFactoryBean

import org.apache.ibatis.plugin.Interceptor; //導入依賴的package包/類
@Bean
public SqlSessionFactoryBean createSqlSessionFactoryBean() throws IOException {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(env.getProperty("mybatis.config-location")));
    PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver = new PathMatchingResourcePatternResolver();
    String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + env.getProperty("mybatis.mapper-locations");
    sqlSessionFactoryBean.setMapperLocations(pathMatchingResourcePatternResolver.getResources(packageSearchPath));
    sqlSessionFactoryBean.setDataSource(dataSource());

    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("reasonable", env.getProperty("pageHelper.reasonable"));
    properties.setProperty("supportMethodsArguments", env.getProperty("pageHelper.supportMethodsArguments"));
    properties.setProperty("returnPageInfo", env.getProperty("pageHelper.returnPageInfo"));
    properties.setProperty("params", env.getProperty("pageHelper.params"));
    pageHelper.setProperties(properties);
    sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});

    return sqlSessionFactoryBean;
}
 
開發者ID:myopenresources,項目名稱:cc-s,代碼行數:21,代碼來源:MyBatisConfig.java

示例7: read2SqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:Lengchuan,項目名稱:SpringBoot-Study,代碼行數:31,代碼來源:Read2DruidDataSourceConfig.java

示例8: read1SqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:Lengchuan,項目名稱:SpringBoot-Study,代碼行數:31,代碼來源:Read1DruidDataSourceConfig.java

示例9: masterSqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:Lengchuan,項目名稱:SpringBoot-Study,代碼行數:32,代碼來源:MasterDruidDataSourceConfig.java

示例10: clusterSqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:Lengchuan,項目名稱:SpringBoot-Study,代碼行數:31,代碼來源:ClusterDruidDataSourceConfig.java

示例11: cluster1SqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:Lengchuan,項目名稱:SpringBoot-Study,代碼行數:31,代碼來源:Cluster1DruidDataSourceConfig.java

示例12: createSqlSessionFactoryBean

import org.apache.ibatis.plugin.Interceptor; //導入依賴的package包/類
protected final AbstractBeanDefinition createSqlSessionFactoryBean(String dataSourceName, String mapperPackage,
		String typeAliasesPackage, Dialect dialect, Configuration configuration) {
	configuration.setDatabaseId(dataSourceName);
	BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(SqlSessionFactoryBean.class);
	bdb.addPropertyValue("configuration", configuration);
	bdb.addPropertyValue("failFast", true);
	bdb.addPropertyValue("typeAliases", this.saenTypeAliases(typeAliasesPackage));
	bdb.addPropertyReference("dataSource", dataSourceName);
	bdb.addPropertyValue("plugins", new Interceptor[] { new CustomPageInterceptor(dialect) });
	if (!StringUtils.isEmpty(mapperPackage)) {
		try {
			mapperPackage = new StandardEnvironment().resolveRequiredPlaceholders(mapperPackage);
			String mapperPackages = ClassUtils.convertClassNameToResourcePath(mapperPackage);
			String mapperPackagePath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + mapperPackages + "/*.xml";
			Resource[] resources = new PathMatchingResourcePatternResolver().getResources(mapperPackagePath);
			bdb.addPropertyValue("mapperLocations", resources);
		} catch (Exception e) {
			log.error("初始化失敗", e);
			throw new RuntimeException( String.format("SqlSessionFactory 初始化失敗  mapperPackage=%s", mapperPackage + ""));
		}
	}
	return bdb.getBeanDefinition();
}
 
開發者ID:halober,項目名稱:spring-boot-starter-dao,代碼行數:24,代碼來源:AbstractDataBaseBean.java

示例13: sqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:swxiao,項目名稱:bubble2,代碼行數:19,代碼來源:MyBatisConfig.java

示例14: sqlSessionFactoryBean

import org.apache.ibatis.plugin.Interceptor; //導入依賴的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();
}
 
開發者ID:pandboy,項目名稱:pingguopai,代碼行數:23,代碼來源:MybatisConfigurer.java

示例15: sqlSessionFactory

import org.apache.ibatis.plugin.Interceptor; //導入依賴的package包/類
@Bean(name="sqlSessionFactory")
@ConditionalOnMissingBean
public SqlSessionFactory sqlSessionFactory() {
    try {
        SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
        sessionFactory.setDataSource(dataSource);
        sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        sessionFactory.setMapperLocations(resolver.getResources(mapperLocations));
        
        PageInterceptor pageInterceptor = new MysqlPageInterceptor();
        sessionFactory.setPlugins(new Interceptor[]{pageInterceptor});
        return sessionFactory.getObject();
    } catch (Exception e) {
        logger.warn("Could not confiure mybatis session factory", e);
        return null;
    }
}
 
開發者ID:lemon-china,項目名稱:lemon-dubbo-message,代碼行數:19,代碼來源:MybatisConfiguration.java


注:本文中的org.apache.ibatis.plugin.Interceptor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。