use of com.baomidou.mybatisplus.core.MybatisConfiguration in project zhili-dataplatform by javasqlbug.
the class SpringConnectionFactory method sqlSessionFactory.
/**
* * get sql session factory
*
* @return sqlSessionFactory
* @throws Exception sqlSessionFactory exception
*/
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
MybatisConfiguration configuration = new MybatisConfiguration();
configuration.setMapUnderscoreToCamelCase(true);
configuration.setCacheEnabled(false);
configuration.setCallSettersOnNulls(true);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.addInterceptor(paginationInterceptor());
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
sqlSessionFactoryBean.setConfiguration(configuration);
sqlSessionFactoryBean.setDataSource(dataSource());
GlobalConfig.DbConfig dbConfig = new GlobalConfig.DbConfig();
dbConfig.setIdType(IdType.AUTO);
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setDbConfig(dbConfig);
sqlSessionFactoryBean.setGlobalConfig(globalConfig);
sqlSessionFactoryBean.setTypeAliasesPackage("com.niezhili.dataplatform.metadata.dao.entity");
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("com/niezhili/dataplatform/metadata/dao/mapper/*Mapper.xml"));
sqlSessionFactoryBean.setTypeEnumsPackage("com.niezhili.dataplatform.metadata.dao.*.enums");
sqlSessionFactoryBean.setDatabaseIdProvider(databaseIdProvider());
return sqlSessionFactoryBean.getObject();
}
use of com.baomidou.mybatisplus.core.MybatisConfiguration in project zhili-dataplatform by javasqlbug.
the class SpringConnectionFactory method sqlSessionFactory.
/**
* * get sql session factory
*
* @return sqlSessionFactory
* @throws Exception sqlSessionFactory exception
*/
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
MybatisConfiguration configuration = new MybatisConfiguration();
configuration.setMapUnderscoreToCamelCase(true);
configuration.setCacheEnabled(false);
configuration.setCallSettersOnNulls(true);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.addInterceptor(paginationInterceptor());
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
sqlSessionFactoryBean.setConfiguration(configuration);
sqlSessionFactoryBean.setDataSource(dataSource());
GlobalConfig.DbConfig dbConfig = new GlobalConfig.DbConfig();
dbConfig.setIdType(IdType.AUTO);
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setDbConfig(dbConfig);
sqlSessionFactoryBean.setGlobalConfig(globalConfig);
sqlSessionFactoryBean.setTypeAliasesPackage("com.niezhili.dataplatform.dataservice.dao.entity");
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("com/niezhili/dataplatform/dataservice/dao/mapper/*Mapper.xml"));
sqlSessionFactoryBean.setTypeEnumsPackage("com.niezhili.dataplatform.dataservice.dao.*.enums");
sqlSessionFactoryBean.setDatabaseIdProvider(databaseIdProvider());
return sqlSessionFactoryBean.getObject();
}
use of com.baomidou.mybatisplus.core.MybatisConfiguration in project solon by noear.
the class MybatisAdapterPlus method initConfiguration.
/**
* 初始化配置
*/
@Override
protected void initConfiguration(Environment environment) {
// for configuration section
config = new MybatisConfiguration(environment);
Props cfgProps = dsProps.getProp("configuration");
if (cfgProps.size() > 0) {
Utils.injectProperties(config, cfgProps);
}
// for globalConfig section
globalConfig = new GlobalConfig().setDbConfig(new GlobalConfig.DbConfig());
Props globalProps = dsProps.getProp("globalConfig");
if (globalProps.size() > 0) {
// 尝试配置注入
Utils.injectProperties(globalConfig, globalProps);
}
GlobalConfigUtils.setGlobalConfig(config, globalConfig);
}
use of com.baomidou.mybatisplus.core.MybatisConfiguration in project springboot-templet-start by thedestiny.
the class MybatisPlusConfigSecondDatasource method secSqlSessionFactory.
// sec
@Bean("secSqlSessionFactory")
public SqlSessionFactory secSqlSessionFactory(@Qualifier("secDatasource") DataSource dataSource) throws Exception {
MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
sqlSessionFactory.setDataSource(dataSource);
MybatisConfiguration configuration = new MybatisConfiguration();
configuration.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setMapUnderscoreToCamelCase(true);
configuration.setCacheEnabled(false);
sqlSessionFactory.setConfiguration(configuration);
sqlSessionFactory.setTypeAliasesPackage("com.destiny.hiootamus.entity.second");
sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/second/*.xml"));
sqlSessionFactory.setPlugins(plusInterceptor);
sqlSessionFactory.setGlobalConfig(new GlobalConfig().setBanner(false));
return sqlSessionFactory.getObject();
}
use of com.baomidou.mybatisplus.core.MybatisConfiguration in project scaleph by flowerfine.
the class LogDataSourceConfig method logSqlSessionFactory.
@Bean(LOG_SQL_SESSION_FACTORY)
public SqlSessionFactory logSqlSessionFactory() throws Exception {
MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
MybatisPlusProperties props = new MybatisPlusProperties();
props.setMapperLocations(new String[] { LOG_MAPPER_XML_PATH });
factoryBean.setMapperLocations(props.resolveMapperLocations());
MybatisConfiguration configuration = new MybatisConfiguration();
configuration.setMapUnderscoreToCamelCase(true);
configuration.setLogImpl(Slf4jImpl.class);
factoryBean.setConfiguration(configuration);
factoryBean.setDataSource(logDataSource());
factoryBean.setTypeAliasesPackage(LOG_ENTITY_PACKAGE);
factoryBean.setPlugins(mybatisPlusInterceptor);
return factoryBean.getObject();
}
Aggregations