Mybatis使用Druid的相关配置

  1. pom.xml文件

            com.alibaba
            druid
            1.1.14
        
  1. mybatis-config.xml文件

        
            

                
            
                    
                
                
                
                
                
                
            
        
    
  1. 创建连接池的相关类
public class DruidDataSourceFactory extends UnpooledDataSourceFactory {
    public DruidDataSourceFactory() {
        this.dataSource = new DruidDataSource();
    }

    @Override
    public DataSource getDataSource() {
        try {
            ((DruidDataSource) this.dataSource).init();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return this.dataSource;
    }
}

你可能感兴趣的:(mybatis,mybatis,java)