Mapper代理开发

       //加载mybatis核心文件
       String resoures =  "mybatis-config.xml";
       InputStream resourceAsStream = Resources.getResourceAsStream(resoures);
       SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
       //获取sqlsessio对象执行sql
       SqlSession sqlSession = sessionFactory.openSession();
       Dim mapper = sqlSession.getMapper(Dim.class);
       List<Demo01> demo01s = mapper.selectAll();
       System.out.println(demo01s);
       //释放输入流
       sqlSession.close();

您可能还喜欢...