當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。