初涉mybatis,有哪些长尾词技巧可以让我快速上手?
- 内容介绍
- 文章标签
- 相关推荐
本文共计442个文字,预计阅读时间需要2分钟。
javapublic class Test { static SqlSessionFactory sqlSessionFactory;
public static void main(String[] args) { SqlSession session1=getSqlSession(); IUserInfoDao dao=session1.getMapper(IUserInfoDao.class); }}
public class Test { static SqlSessionFactory sqlSessionFactory; public static void main(String[] args) { SqlSession session1 = getSqlSession(); //面向接口,必须这样实现 IUserInfoDao dao = session1.getMapper(IUserInfoDao.class); System.out.println(dao.getUserById(1)); } private static SqlSession getSqlSession() { return sqlSessionFactory.openSession(); } static{ try { String resource = "mybatis.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); } catch (Exception e) { throw new RuntimeException(e); } } } mybatis.xml
本文共计442个文字,预计阅读时间需要2分钟。
javapublic class Test { static SqlSessionFactory sqlSessionFactory;
public static void main(String[] args) { SqlSession session1=getSqlSession(); IUserInfoDao dao=session1.getMapper(IUserInfoDao.class); }}
public class Test { static SqlSessionFactory sqlSessionFactory; public static void main(String[] args) { SqlSession session1 = getSqlSession(); //面向接口,必须这样实现 IUserInfoDao dao = session1.getMapper(IUserInfoDao.class); System.out.println(dao.getUserById(1)); } private static SqlSession getSqlSession() { return sqlSessionFactory.openSession(); } static{ try { String resource = "mybatis.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); } catch (Exception e) { throw new RuntimeException(e); } } } mybatis.xml

