All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.autoconfigure.mybatis.MyBatisAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.mybatis;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.application.condition.ConditionalOnJdwpEnabled;
import org.zodiac.autoconfigure.application.jvm.AppJvmProperties;
import org.zodiac.commons.util.IdGenerator;

@SpringBootConfiguration
//@PropertySource(value = "classpath:/META-INF/config/mybatis.properties")
@ConditionalOnClass(value = {
    org.apache.ibatis.type.TypeHandler.class,
    org.zodiac.mybatis.MyBatisApplicationRunListener.class,
    org.apache.ibatis.session.SqlSessionFactory.class
//    tk.mybatis.mapper.autoconfigure.MapperAutoConfiguration.class,
//    org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration.class,
//    com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration.class
})
@AutoConfigureBefore(value = {
    org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration.class,
//    tk.mybatis.mapper.autoconfigure.MapperAutoConfiguration.class,
//    com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration.class
})
public class MyBatisAutoConfiguration /*extends org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration*/ {

//    public MyBatisAutoConfiguration(org.mybatis.spring.boot.autoconfigure.MybatisProperties properties,
//                                ObjectProvider interceptorsProvider,
//                                ObjectProvider typeHandlersProvider,
//                                ObjectProvider languageDriversProvider,
//                                ResourceLoader resourceLoader,
//                                ObjectProvider databaseIdProvider,
//                                ObjectProvider> configurationCustomizersProvider) {
//        super(properties, interceptorsProvider, typeHandlersProvider, languageDriversProvider,
//            resourceLoader, databaseIdProvider, configurationCustomizersProvider);
//    }

    public MyBatisAutoConfiguration() {
    }

    @Bean
    @ConfigurationProperties(prefix = org.zodiac.mybatis.constants.MyBatisSystemPropertiesConstants.MYBATIS_PREFIX, ignoreInvalidFields = true)
    protected MyBatisProperties myBatisProperties() {
        return new MyBatisProperties();
    }

    @Bean
    @ConditionalOnMissingBean
    @ConfigurationProperties(prefix = org.zodiac.mybatis.constants.MyBatisSystemPropertiesConstants.MYBATIS_HOTSPOT_PREFIX)
    @ConditionalOnJdwpEnabled(enabledProperty = org.zodiac.mybatis.constants.MyBatisSystemPropertiesConstants.MYBATIS_HOTSPOT_ENABLED)
    protected MybatisHotSpotLoaderProperties mybatisHotSpotLoaderProperties() {
        return new MybatisHotSpotLoaderProperties();
    }

    @Bean
    @ConditionalOnMissingBean(name = org.zodiac.mybatis.constants.MyBatisConstants.MYBATIS_DEFAULT_ID_GENERATOR_BEAN_NAME)
    protected IdGenerator mybatisDefaultIdGenerator() {
        return new IdGenerator() {};
    }

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnBean(value = {org.mybatis.spring.SqlSessionFactoryBean.class})
    protected org.zodiac.mybatis.support.SqlSessionMapperHotspotLoader sqlSessionMapperHotspotLoader(AppJvmProperties appJvmProperties,
        org.mybatis.spring.SqlSessionFactoryBean sessionFactory) {
        return new org.zodiac.mybatis.support.SqlSessionMapperHotspotLoader(sessionFactory, appJvmProperties);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy