use of com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean 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.extension.spring.MybatisSqlSessionFactoryBean in project wakaka by Crysmart.
the class MyBatisConfig method sqlSessionFactoryBean.
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactoryBean(DataSourceProxy dataSourceProxy) throws Exception {
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
bean.setDataSource(dataSourceProxy);
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
// bean.setConfigLocation(resolver.getResource("classpath:mybatis-config.xml"));
bean.setMapperLocations(resolver.getResources("classpath*:mybatis/**/*-mapper.xml"));
SqlSessionFactory factory = null;
try {
factory = bean.getObject();
} catch (Exception e) {
throw new RuntimeException(e);
}
return factory;
}
use of com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean in project wakaka by Crysmart.
the class MyBatisConfig method sqlSessionFactoryBean.
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactoryBean(DataSourceProxy dataSourceProxy) throws Exception {
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
bean.setDataSource(dataSourceProxy);
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
// bean.setConfigLocation(resolver.getResource("classpath:mybatis-config.xml"));
bean.setMapperLocations(resolver.getResources("classpath*:mybatis/**/*-mapper.xml"));
SqlSessionFactory factory = null;
try {
factory = bean.getObject();
} catch (Exception e) {
throw new RuntimeException(e);
}
return factory;
}
use of com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean 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.extension.spring.MybatisSqlSessionFactoryBean 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