首页 > 代码库 > 测试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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。