标签:mybatis lis resources print sql语句 bat imp nfa stream
1.加jar包,2个jar包(mybatis,jar,mybatis-connet-java.jar)
2.配置xml,properils
3.书写sql语句即**.xml
4.启动测试
@Test
public void getAllUser(){
//1.启动mybatis框架
//SqlSession-->SqlSessionFactory-->SqlSessionFactioryBuilder
SqlSessionFactoryBuilder sb=new SqlSessionFactoryBuilder ();
InputSteam ins=Resources.getResourcesAsStream("mybatis.xml");
SqlSessionFactory ssf = sfb.build.get(ins);
sqlSession session =ssf.openSession();
List<User> list = session.selectList("cn.java.dao.impl.userDaoImpl.getAllUser");
for(User user:list){
System.out.println(user);
}
}
session.selectList()多条,
session.selectOne(路径,参数);单条
标签:mybatis lis resources print sql语句 bat imp nfa stream
原文地址:https://www.cnblogs.com/gzhbk/p/9498879.html