@Configuration
@ConditionalOnClass(value={org.apache.ibatis.session.SqlSessionFactory.class,org.mybatis.spring.SqlSessionFactoryBean.class})
@ConditionalOnSingleCandidate(value=javax.sql.DataSource.class)
@EnableConfigurationProperties(value=MybatisProperties.class)
@AutoConfigureAfter(value={org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class,MybatisLanguageDriverAutoConfiguration.class})
public class MybatisAutoConfiguration
extends Object
Auto-Configuration for Mybatis. Contributes a SqlSessionFactory and a
SqlSessionTemplate.
If org.mybatis.spring.annotation.MapperScan is used, or a configuration file is specified as a property,
those will be considered, otherwise this auto-configuration will attempt to register mappers based on the interface
definitions in or under the root auto-configuration package.
由于在Spring事务中通过SqlSessionUtils.getSqlSession(SqlSessionFactory)方法获取SqlSession,不支持对相同SqlSessionFactory下的连接进行ExecutorType模式切换,所以此处自动构建两个SqlSessionFactory,一为默认模式(通常为ExecutorType.SIMPLE),一为ExecutorType.BATCH模式
| 限定符和类型 | 类和说明 |
|---|---|
static class |
MybatisAutoConfiguration.AutoConfiguredMapperScannerRegistrar
This will just scan the same base package as Spring Boot does.
|
static class |
MybatisAutoConfiguration.MapperScannerRegistrarNotFoundConfiguration
If mapper registering configuration or mapper scanning configuration not present, this configuration allow to scan
mappers based on the same component-scanning path as Spring Boot itself.
|
static class |
MybatisAutoConfiguration.SqlSessionFactoryConfiguration |
static class |
MybatisAutoConfiguration.SqlSessionTemplateConfiguration |
| 构造器和说明 |
|---|
MybatisAutoConfiguration() |
Copyright © 2024 fossc. All rights reserved.