@Test
public void testSelectById() throws Exception {
// 接受参数
int id = 1;
// 1. 获取SqlSessionFactory
// 1. 加载mybatis的核心配置文件,获取SqlSessionFactory
// 1. 加载mybatis的核心配置文件,获取SqlSessionFactory (sql会话工厂)
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
// 2. 获取SqlSession对象
SqlSession sqlSession = sqlSessionFactory.openSession();
//3. 获取Mapper接口的代理对象
BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);// 将该接口的的class对象,传进去,就可以获得该借口的代理对象
// 4. 执行方法:
Brand brand = brandMapper.selectById(id);
System.out.println(brand);
// 5. 释放资源
sqlSession.close();
}