mybatis(核心配置文件的配置)

 

 

properties标签


    

 

 

settings标签

mybatis(核心配置文件的配置)_第1张图片

mybatis(核心配置文件的配置)_第2张图片

 

typeAliases(配置别名相关的操作)


        
        
        
        
        <package name="com.mybatis.bean"/>
        
        
    

 

typeHandlers标签(类型处理器相关)

mybatis(核心配置文件的配置)_第3张图片

 mybatis(核心配置文件的配置)_第4张图片

 

plugins标签(插件相关)

mybatis(核心配置文件的配置)_第5张图片

mybatis(核心配置文件的配置)_第6张图片

 

environments(配置各种环境)

 

 

org.apache.ibatis.session.Configuration

public Configuration() {
    typeAliasRegistry.registerAlias("JDBC", JdbcTransactionFactory.class);
    typeAliasRegistry.registerAlias("MANAGED", ManagedTransactionFactory.class);

    typeAliasRegistry.registerAlias("JNDI", JndiDataSourceFactory.class);
    typeAliasRegistry.registerAlias("POOLED", PooledDataSourceFactory.class);
    typeAliasRegistry.registerAlias("UNPOOLED", UnpooledDataSourceFactory.class);
}

         

         
    default="development">
        
            
            
                
                
                
                
            
        
    
        
            
            
                
                
                
                
            
        
    
public class PooledDataSourceFactory extends UnpooledDataSourceFactory {

  public PooledDataSourceFactory() {
    this.dataSource = new PooledDataSource();
  }

}

public class UnpooledDataSourceFactory implements DataSourceFactory {

  private static final String DRIVER_PROPERTY_PREFIX = "driver.";
  private static final int DRIVER_PROPERTY_PREFIX_LENGTH = DRIVER_PROPERTY_PREFIX.length();

  protected DataSource dataSource;

  public UnpooledDataSourceFactory() {
    this.dataSource = new UnpooledDataSource();
  }
}

 

 databaseIdProvider(支持多数据源)

typeAliasRegistry.registerAlias("DB_VENDOR", VendorDatabaseIdProvider.class);