当前位置: 首页>>代码示例>>Java>>正文


Java SqlSessionFactoryBean.setTypeHandlersPackage方法代码示例

本文整理汇总了Java中org.mybatis.spring.SqlSessionFactoryBean.setTypeHandlersPackage方法的典型用法代码示例。如果您正苦于以下问题:Java SqlSessionFactoryBean.setTypeHandlersPackage方法的具体用法?Java SqlSessionFactoryBean.setTypeHandlersPackage怎么用?Java SqlSessionFactoryBean.setTypeHandlersPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mybatis.spring.SqlSessionFactoryBean的用法示例。


在下文中一共展示了SqlSessionFactoryBean.setTypeHandlersPackage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: historySqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public static SqlSessionFactoryBean historySqlSessionFactory(DataSource historyDataSource) throws Exception {
  SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
  sessionFactory.setDataSource(historyDataSource);
  sessionFactory.setTypeHandlersPackage("cern.c2mon.server.history.mapper");

  VendorDatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider();
  Properties properties = new Properties();
  properties.putAll(ImmutableMap.of(
      "HSQL", "oracle",
      "Oracle", "oracle",
      "MySQL", "mysql"
  ));
  databaseIdProvider.setProperties(properties);

  sessionFactory.setDatabaseIdProvider(databaseIdProvider);
  return sessionFactory;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:19,代码来源:HistoryDataSourceConfig.java

示例2: 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();
}
 
开发者ID:tinyoculus,项目名称:Dynamic-data-sources,代码行数:19,代码来源:MybatisAutoConfiguration.java

示例3: 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);
    factory.setVfs(SpringBootVFS.class);
    if (StringUtils.hasText(this.properties.getConfigLocation())) {
        factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
    }
    org.apache.ibatis.session.Configuration configuration = this.properties.getConfiguration();
    if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) {
        configuration = new org.apache.ibatis.session.Configuration();
    }
    factory.setConfiguration(configuration);
    if (this.properties.getConfigurationProperties() != null) {
        factory.setConfigurationProperties(this.properties.getConfigurationProperties());
    }
    if (!ObjectUtils.isEmpty(this.interceptors)) {
        factory.setPlugins(this.interceptors);
    }
    if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
        factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
    }
    if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
        factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
    }
    if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
        factory.setMapperLocations(this.properties.resolveMapperLocations());
    }

    return factory.getObject();
}
 
开发者ID:weiwei02,项目名称:Yoghurt,代码行数:33,代码来源:MybatisAutoConfiguration.java

示例4: configSqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public static SqlSessionFactoryBean configSqlSessionFactory(DataSource configurationDataSource,
                                                            VendorDatabaseIdProvider databaseIdProvider) throws Exception {
  SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
  sessionFactory.setDataSource(configurationDataSource);
  sessionFactory.setTypeHandlersPackage("cern.c2mon.server.configuration.mybatis");
  sessionFactory.setDatabaseIdProvider(databaseIdProvider);
  return sessionFactory;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:10,代码来源:ConfigDataSourceConfig.java

示例5: cacheSqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public static SqlSessionFactoryBean cacheSqlSessionFactory(DataSource cacheDataSource) throws Exception {
  SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
  sessionFactory.setDataSource(cacheDataSource);
  sessionFactory.setDatabaseIdProvider(databaseIdProvider());
  sessionFactory.setTypeHandlersPackage("cern.c2mon.server.cache.dbaccess.type");
  return sessionFactory;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:9,代码来源:CacheDataSourceConfig.java

示例6: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
@ConditionalOnMissingBean
public SqlSessionFactory sqlSessionFactory(final DataSource dataSource,
                                           final MyBatisProperties properties) throws Exception {
    final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
    sessionFactory.setDataSource(dataSource);
    sessionFactory.setTypeAliasesPackage(properties.getAliasesPackage());
    sessionFactory.setTypeHandlersPackage(properties.getTypeHandlersPackage());
    sessionFactory.setMapperLocations(properties.getMapperLocations());
    sessionFactory.setPlugins(interceptors);
    return sessionFactory.getObject();
}
 
开发者ID:create1st,项目名称:spring-boot-starter-mybatis,代码行数:13,代码来源:MyBatisAutoConfiguration.java

示例7: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
/**
 * 定义sqlSessionFactory的bean
 *
 * @param dataSource
 * @return
 * @throws Exception
 */
@Bean(name = "sqlSessionFactory")
@ConditionalOnMissingBean
//不允许特定的bean出现来跳过配置
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
	SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
	sqlSessionFactoryBean.setDataSource(dataSource);
	sqlSessionFactoryBean.setVfs(SpringBootVFS.class);
	if (StringUtils.hasText(this.properties.getConfigLocation())) {
		sqlSessionFactoryBean.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
	}

	sqlSessionFactoryBean.setConfiguration(properties.getConfiguration());
	if (!ObjectUtils.isEmpty(this.interceptors)) {
		sqlSessionFactoryBean.setPlugins(this.interceptors);
	}
	if (this.databaseIdProvider != null) {
		sqlSessionFactoryBean.setDatabaseIdProvider(this.databaseIdProvider);
	}
	if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
		sqlSessionFactoryBean.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
	}
	if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
		sqlSessionFactoryBean.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
	}
	if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
		sqlSessionFactoryBean.setMapperLocations(this.properties.resolveMapperLocations());
	}
	sqlSessionFactoryBean.setMybatisRefreshProperties(mybatisRefreshProperties);
	return sqlSessionFactoryBean.getObject();
}
 
开发者ID:whatlookingfor,项目名称:spring-boot-sample,代码行数:38,代码来源:MybatisConfig.java

示例8: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
@ConditionalOnMissingBean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
  SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
  factory.setDataSource(dataSource);
  factory.setVfs(SpringBootVFS.class);
  if (StringUtils.hasText(this.properties.getConfigLocation())) {
    factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
  }
  Configuration configuration = this.properties.getConfiguration();
  if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) {
    configuration = new Configuration();
  }
  if (configuration != null && !CollectionUtils.isEmpty(this.configurationCustomizers)) {
    for (ConfigurationCustomizer customizer : this.configurationCustomizers) {
      customizer.customize(configuration);
    }
  }
  factory.setConfiguration(configuration);
  if (this.properties.getConfigurationProperties() != null) {
    factory.setConfigurationProperties(this.properties.getConfigurationProperties());
  }
  if (!ObjectUtils.isEmpty(this.interceptors)) {
    factory.setPlugins(this.interceptors);
  }
  if (this.databaseIdProvider != null) {
    factory.setDatabaseIdProvider(this.databaseIdProvider);
  }
  if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
    factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
  }
  if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
    factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
  }
  if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
    factory.setMapperLocations(this.properties.resolveMapperLocations());
  }

  return factory.getObject();
}
 
开发者ID:mybatis,项目名称:spring-boot-starter,代码行数:41,代码来源:MybatisAutoConfiguration.java

示例9: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean
SqlSessionFactory sqlSessionFactory(DataSource ds) throws Exception {
    SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
    factoryBean.setDataSource(ds);
    String typeAliasesPackage = BaseEntity.class.getPackage().getName();
    factoryBean.setTypeAliasesPackage(typeAliasesPackage);
    factoryBean.setTypeHandlersPackage(typeAliasesPackage);
    factoryBean.setConfigLocation(new ClassPathResource("mybatis-config.xml"));
    //Use velocity as the scripting language for mapper
    factoryBean.setTypeAliases(new Class<?>[]{VelocityDriver.class});
    return factoryBean.getObject();
}
 
开发者ID:dantesun,项目名称:webapp-boilerplate,代码行数:13,代码来源:PersistenceConfig.java

示例10: DbH2SqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //导入方法依赖的package包/类
@Bean(name = "dbH2SqlSessionFactory")
public SqlSessionFactory DbH2SqlSessionFactory() throws Exception {
	SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();

	sqlSessionFactoryBean.setDataSource(dbH2DataSource());
	sqlSessionFactoryBean.setTypeHandlersPackage("");

	sqlSessionFactoryBean.setConfigLocation(new ClassPathResource("/spring4_2015Config/mybatis-db-config.xml"));
	return sqlSessionFactoryBean.getObject();
}
 
开发者ID:sdcuike,项目名称:spring4-2015,代码行数:11,代码来源:DataSourceConfig.java


注:本文中的org.mybatis.spring.SqlSessionFactoryBean.setTypeHandlersPackage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。