public class CountryMapperTest {
    private static SqlSessionFactory sqlSessionFactory;

    @BeforeClass
    public static void init() {
        try {
            Reader reader = Resources.getResourceAsReader("mybatis-config.xml");
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
            reader.close();
        } catch (IOException ignore) {
            ignore.printStackTrace();
        }
    }

    @Test
    public void testSelectAll() {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        try {
            List<CountryEntity> countryList = sqlSession.selectList("TestList");
            printCountryList(countryList);
        } finally {
            //不要忘记关闭 sqlSession
            sqlSession.close();
        }
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-12-24
  • 2021-05-15
  • 2022-03-08
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
  • 2021-10-10
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
相关资源
相似解决方案