当前位置: 首页>>代码示例>>Java>>正文


Java Resources.getResourceAsReader方法代码示例

本文整理汇总了Java中org.apache.ibatis.io.Resources.getResourceAsReader方法的典型用法代码示例。如果您正苦于以下问题:Java Resources.getResourceAsReader方法的具体用法?Java Resources.getResourceAsReader怎么用?Java Resources.getResourceAsReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.io.Resources的用法示例。


在下文中一共展示了Resources.getResourceAsReader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    System.out.println("Starting up CmsCmProcessor tests");
 String resource = "mybatis-config.xml";
 Reader reader = Resources.getResourceAsReader( resource );
 SqlSessionFactory sf = new SqlSessionFactoryBuilder().build(reader);
    session = sf.openSession();
 clazzMapper = session.getMapper(ClazzMapper.class);
    ciMapper = session.getMapper(CIMapper.class);
    mdValidator = new CmsMdValidator();
    cmValidator = new CmsCmValidator();
 mdProcessor = new CmsMdProcessor();
 mdProcessor.setClazzMapper( clazzMapper );
 mdProcessor.setMdValidator(mdValidator);
    cmProcessor = new CmsCmProcessor();
    cmProcessor.setCiMapper(ciMapper);
    cmProcessor.setMdProcessor(mdProcessor);
    cmProcessor.setCmValidator(cmValidator);
    RelationMapper relationMapper=session.getMapper(RelationMapper.class);
    mdProcessor.setRelationMapper(relationMapper);
    
}
 
开发者ID:oneops,项目名称:oneops,代码行数:23,代码来源:CmsCmProcessorTest.java

示例2: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create an SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/maptypehandler/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/maptypehandler/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:MapTypeHandlerTest.java

示例3: initSqlSessionFactory

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void initSqlSessionFactory() throws Exception {
  Connection conn = null;

  try {
    Class.forName("org.hsqldb.jdbcDriver");
    conn = DriverManager.getConnection("jdbc:hsqldb:mem:heavy_initial_load", "sa", "");

    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/heavy_initial_load/ibatisConfig.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();
  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:18,代码来源:HeavyInitialLoadTest.java

示例4: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create an SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/array_result_type/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/array_result_type/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:ArrayResultTypeTest.java

示例5: initDatabase

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void initDatabase() throws Exception {
  Connection conn = null;

  try {
    Class.forName("org.hsqldb.jdbcDriver");
    conn = DriverManager.getConnection("jdbc:hsqldb:mem:order_prefix_removed", "sa", "");

    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/order_prefix_removed/CreateDB.sql");

    ScriptRunner runner = new ScriptRunner(conn);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(null);
    runner.runScript(reader);
    conn.commit();
    reader.close();

    reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/order_prefix_removed/ibatisConfig.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();
  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:27,代码来源:OrderPrefixRemoved.java

示例6: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader(XML);
  try {
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  } finally {
    reader.close();
  }

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  try {
    Connection conn = session.getConnection();
    reader = Resources.getResourceAsReader(SQL);
    try {
      ScriptRunner runner = new ScriptRunner(conn);
      runner.setLogWriter(null);
      runner.runScript(reader);
    } finally {
      reader.close();
    }
  } finally {
    session.close();
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:27,代码来源:DmlMapperReturnTypesTest.java

示例7: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/inheritance/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/inheritance/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:InheritanceTest.java

示例8: testRefCursor1

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testRefCursor1() throws IOException {
    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/refcursor/MapperConfig.xml");
    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        OrdersMapper mapper = sqlSession.getMapper(OrdersMapper.class);
        Map<String, Object> parameter = new HashMap<String, Object>();
        parameter.put("orderId", 1);
        mapper.getOrder1(parameter);
        
        assertNotNull(parameter.get("order"));
        List<Order> orders = (List<Order>) parameter.get("order");
        assertEquals(1, orders.size());
        Order order = orders.get(0);
        assertEquals(3, order.getDetailLines().size());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:22,代码来源:RefCursorTest.java

示例9: openSession

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
/**
 * Create a session with the specified configuration and initialized the database.
 */
private void openSession(String aConfig) throws Exception {
  final String resource = "org/apache/ibatis/submitted/automatic_lazy_loading/ibatis-automatic-lazy-load-" + aConfig + ".xml";
  Reader batisConfigReader = Resources.getResourceAsReader(resource);

  SqlSessionFactory sqlSessionFactory;
  try {
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(batisConfigReader);
  } catch(Exception anException) {
    throw new RuntimeException("Mapper configuration failed, expected this to work: " + anException.getMessage(), anException);
  }

  SqlSession session = sqlSessionFactory.openSession();

  Connection conn = session.getConnection();
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.setErrorLogWriter(null);
  Reader createScriptReader = Resources.getResourceAsReader("org/apache/ibatis/submitted/automatic_lazy_loading/create.sql");
  runner.runScript(createScriptReader);

  sqlSession = sqlSessionFactory.openSession();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:26,代码来源:AutomaticLazyLoadingTest.java

示例10: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  Connection conn = null;

  try {
    Class.forName("org.hsqldb.jdbcDriver");
    conn = DriverManager.getConnection("jdbc:hsqldb:mem:parent_reference_3level", "sa", "");
    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/parent_reference_3level/CreateDB.sql");
    ScriptRunner runner = new ScriptRunner(conn);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(null);
    runner.runScript(reader);
    conn.commit();
    reader.close();

    reader = Resources.getResourceAsReader(getConfigPath());
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();

  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:26,代码来源:BlogTest.java

示例11: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  Connection conn = null;

  try {
    Class.forName("org.hsqldb.jdbcDriver");
    conn = DriverManager.getConnection("jdbc:hsqldb:mem:parametrizedlist", "sa", "");

    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/parametrizedlist/CreateDB.sql");

    ScriptRunner runner = new ScriptRunner(conn);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(new PrintWriter(System.err));
    runner.runScript(reader);
    conn.commit();
    reader.close();

    reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/parametrizedlist/Config.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();
  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:27,代码来源:ParametrizedListTest.java

示例12: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/parent_childs/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/parent_childs/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:ParentChildTest.java

示例13: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandlerinjection/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().register(handler);
  sqlSessionFactory.getConfiguration().addMapper(Mapper.class);

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandlerinjection/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:21,代码来源:TypeHandlerInjectionTest.java

示例14: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandler/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();
  sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().register(StringTrimmingTypeHandler.class);

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandler/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:19,代码来源:TypeHandlerTest.java

示例15: setUp

import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/rounding/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/rounding/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:RoundingHandlersTest.java


注:本文中的org.apache.ibatis.io.Resources.getResourceAsReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。