gistfile1.txt public class Test {static SqlSessionFactory sqlSessionFactory;public static void main(String[] args) {SqlSession session1 = getSqlSession();//面向接口,必须这样实现IUserInfoDao dao = session1.getMapper(IUserInfoDao.
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
UserInfoMapper.xml
包结构.PNGselect seq.nextval from dual insert into userinfo values(#{id},#{name},#{pwd},#{rolesid})