Search in sources :

Example 1 with MybatisPlusProperties

use of com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties in project scaleph by flowerfine.

the class MasterDataSourceConfig method masterSqlSessionFactory.

@Primary
@Bean(MASTER_SQL_SESSION_FACTORY)
public SqlSessionFactory masterSqlSessionFactory() throws Exception {
    MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
    MybatisPlusProperties props = new MybatisPlusProperties();
    props.setMapperLocations(new String[] { MASTER_MAPPER_XML_PATH });
    factoryBean.setMapperLocations(props.resolveMapperLocations());
    MybatisConfiguration configuration = new MybatisConfiguration();
    configuration.setMapUnderscoreToCamelCase(true);
    configuration.setLogImpl(Slf4jImpl.class);
    factoryBean.setConfiguration(configuration);
    factoryBean.setDataSource(masterDataSource());
    factoryBean.setTypeAliasesPackage(MASTER_ENTITY_PACKAGE);
    factoryBean.setPlugins(mybatisPlusInterceptor);
    return factoryBean.getObject();
}
Also used : MybatisSqlSessionFactoryBean(com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean) MybatisConfiguration(com.baomidou.mybatisplus.core.MybatisConfiguration) MybatisPlusProperties(com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties) Primary(org.springframework.context.annotation.Primary) MybatisSqlSessionFactoryBean(com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with MybatisPlusProperties

use of com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties 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();
}
Also used : MybatisSqlSessionFactoryBean(com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean) MybatisConfiguration(com.baomidou.mybatisplus.core.MybatisConfiguration) MybatisPlusProperties(com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties) MybatisSqlSessionFactoryBean(com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with MybatisPlusProperties

use of com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties in project smart-cloud by smart-cloud.

the class MybatisPlusPropertiesBeanPostProcessor method setDeleteStateEnumPackage.

/**
 * 设置{@link DeleteState}枚举的包名
 *
 * @param bean
 * @return
 */
private Object setDeleteStateEnumPackage(Object bean) {
    if (!(bean instanceof MybatisPlusProperties)) {
        return bean;
    }
    String deleteStatePackage = DeleteState.class.getPackage().getName();
    MybatisPlusProperties mybatisPlusProperties = (MybatisPlusProperties) bean;
    String typeEnumsPackage = mybatisPlusProperties.getTypeEnumsPackage();
    if (StringUtils.isNotBlank(typeEnumsPackage)) {
        typeEnumsPackage += SymbolConstant.COMMA + deleteStatePackage;
    } else {
        typeEnumsPackage = deleteStatePackage;
    }
    mybatisPlusProperties.setTypeEnumsPackage(typeEnumsPackage);
    return bean;
}
Also used : DeleteState(org.smartframework.cloud.starter.mybatis.plus.enums.DeleteState) MybatisPlusProperties(com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties)

Aggregations

MybatisPlusProperties (com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties)3 MybatisConfiguration (com.baomidou.mybatisplus.core.MybatisConfiguration)2 MybatisSqlSessionFactoryBean (com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean)2 Bean (org.springframework.context.annotation.Bean)2 DeleteState (org.smartframework.cloud.starter.mybatis.plus.enums.DeleteState)1 Primary (org.springframework.context.annotation.Primary)1