首页 > 代码库 > 测试3

测试3

显示一段代码   " 显示代码  行内代码 

 1 public class SqlSessionFactoryBuilder { 2  3   //Reader读取mybatis配置文件,传入构造方法 4   //除了Reader外,其实还有对应的inputStream作为参数的构造方法, 5   //这也体现了mybatis配置的灵活性 6   public SqlSessionFactory build(Reader reader) { 7     return build(reader, null, null); 8   } 9 10   public SqlSessionFactory build(Reader reader, String environment) {11     return build(reader, environment, null);12   }13   14   //mybatis配置文件 + properties, 此时mybatis配置文件中可以不配置properties,也能使用${}形式15   public SqlSessionFactory build(Reader reader, Properties properties) {16     return build(reader, null, properties);17   }18   19   //通过XMLConfigBuilder解析mybatis配置,然后创建SqlSessionFactory对象20   public SqlSessionFactory build(Reader reader, String environment, Properties properties) {21     try {22       XMLConfigBuilder parser = new XMLConfigBuilder(reader, environment, properties);23       //下面看看这个方法的源码24       return build(parser.parse());25     } catch (Exception e) {26       throw ExceptionFactory.wrapException("Error building SqlSession.", e);27     } finally {28       ErrorContext.instance().reset();29       try {30         reader.close();31       } catch (IOException e) {32         // Intentionally ignore. Prefer previous error.33       }34     }35   }36 37   public SqlSessionFactory build(Configuration config) {38     return new DefaultSqlSessionFactory(config);39   }40 41 }

 

只显示代码

 1 public class SqlSessionFactoryBuilder { 2  3   //Reader读取mybatis配置文件,传入构造方法 4   //除了Reader外,其实还有对应的inputStream作为参数的构造方法, 5   //这也体现了mybatis配置的灵活性 6   public SqlSessionFactory build(Reader reader) { 7     return build(reader, null, null); 8   } 9 10   public SqlSessionFactory build(Reader reader, String environment) {11     return build(reader, environment, null);12   }13   14   //mybatis配置文件 + properties, 此时mybatis配置文件中可以不配置properties,也能使用${}形式15   public SqlSessionFactory build(Reader reader, Properties properties) {16     return build(reader, null, properties);17   }18   19   //通过XMLConfigBuilder解析mybatis配置,然后创建SqlSessionFactory对象20   public SqlSessionFactory build(Reader reader, String environment, Properties properties) {21     try {22       XMLConfigBuilder parser = new XMLConfigBuilder(reader, environment, properties);23       //下面看看这个方法的源码24       return build(parser.parse());25     } catch (Exception e) {26       throw ExceptionFactory.wrapException("Error building SqlSession.", e);27     } finally {28       ErrorContext.instance().reset();29       try {30         reader.close();31       } catch (IOException e) {32         // Intentionally ignore. Prefer previous error.33       }34     }35   }36 37   public SqlSessionFactory build(Configuration config) {38     return new DefaultSqlSessionFactory(config);39   }40 41 }

 

测试3