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


Java SqlSessionFactoryBean.setConfigurationProperties方法代碼示例

本文整理匯總了Java中org.mybatis.spring.SqlSessionFactoryBean.setConfigurationProperties方法的典型用法代碼示例。如果您正苦於以下問題:Java SqlSessionFactoryBean.setConfigurationProperties方法的具體用法?Java SqlSessionFactoryBean.setConfigurationProperties怎麽用?Java SqlSessionFactoryBean.setConfigurationProperties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mybatis.spring.SqlSessionFactoryBean的用法示例。


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

示例1: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource) throws IOException {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();

    //mybatis配置
    Properties prop = new Properties();
    prop.setProperty("mapUnderscoreToCamelCase", "true");

    sqlSessionFactoryBean.setConfigurationProperties(prop);
    sqlSessionFactoryBean.setTypeAliasesPackage("com.tc.ly.bean");

    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    Resource[] resources = resolver.getResources("classpath:mapper/*.xml");

    sqlSessionFactoryBean.setMapperLocations(resources);
    sqlSessionFactoryBean.setDataSource(dataSource);

    return sqlSessionFactoryBean;
}
 
開發者ID:hadesvip,項目名稱:ly-security,代碼行數:20,代碼來源:MybatisConfig.java

示例2: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public SqlSessionFactory sqlSessionFactory() {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(dataSource());

    try {
        Properties properties = new Properties();
        properties.put("prefix", env.getProperty("datasource.prefix", ""));
        sqlSessionFactoryBean.setConfigurationProperties(properties);
        sqlSessionFactoryBean
                .setMapperLocations(ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources("classpath:/META-INF/admin-mybatis-mappings/*.xml"));
        sqlSessionFactoryBean.afterPropertiesSet();
        return sqlSessionFactoryBean.getObject();
    } catch (Exception e) {
        throw new RuntimeException("Could not create sqlSessionFactory", e);
    }

}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:19,代碼來源:DatabaseConfiguration.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: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public SqlSessionFactory sqlSessionFactory() {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    DataSource dataSource = dataSource();
    sqlSessionFactoryBean.setDataSource(dataSource);
    String databaseType = initDatabaseType(dataSource);
    if (databaseType == null) {
        throw new FlowableException("couldn't deduct database type");
    }

    try {
        Properties properties = new Properties();
        properties.put("prefix", env.getProperty("datasource.prefix", ""));
        properties.put("blobType", "BLOB");
        properties.put("boolValue", "TRUE");

        properties.load(this.getClass().getClassLoader().getResourceAsStream("org/flowable/db/properties/" + databaseType + ".properties"));

        sqlSessionFactoryBean.setConfigurationProperties(properties);
        sqlSessionFactoryBean
                .setMapperLocations(ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources("classpath:/META-INF/modeler-mybatis-mappings/*.xml"));
        sqlSessionFactoryBean.afterPropertiesSet();
        return sqlSessionFactoryBean.getObject();
    } catch (Exception e) {
        throw new FlowableException("Could not create sqlSessionFactory", e);
    }

}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:29,代碼來源:DatabaseConfiguration.java

示例5: 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

示例6: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
	SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
	sqlSessionFactoryBean.setDataSource(dataSource);
	Properties props = new Properties();
	props.setProperty("key", "value");
	sqlSessionFactoryBean.setConfigurationProperties(props);
	return sqlSessionFactoryBean.getObject();
}
 
開發者ID:mybatis,項目名稱:spring-boot-starter,代碼行數:10,代碼來源:MybatisAutoConfigurationTest.java


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