MyBatis初探之环境的配置(2)

public class Test {
 
 public static void main(String[] args) throws Exception {
  String resource = "conf.xml";
  Reader reader = Resources.getResourceAsReader(resource);
  SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(reader);
  SqlSession session = sessionFactory.openSession();
  String statement = "com.bird.mybatis.bean.userMapper.getUser";
  Users user = session.selectOne(statement, 1);
  System.out.println(user);
 }
}

总体来说还是非常简单的。

MyBatis 的详细介绍请点这里
MyBatis 的下载地址请点这里

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/8b12fa936fdb9c60ab23bff8d929d218.html