public class MyBatisTest {
public SqlSessionFactory sqlSessionFactory;/
@BeforeEach
public void initSqlSessionFactory() throws IOException{
String resource = "config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
sqlSessionFactory= new SqlSessionFactoryBuilder().build(inputStream);
}
@Test
public void testInsert() {
//获取和数据库的一次会话
SqlSession openSession=sqlSessionFactory.openSession();
try {
EmployeeDao employeeDao = openSession.getMapper(EmployeeDao.class);
int i = employeeDao.insertEmployee(new Employee(null,"tomcat" ,"tomcat@163.com", 0));
System.out.println(i);
} finally {
//手动提交
openSession.close();
}
}
}
xml文件都是最普通的,,为啥提交了呢,想不通,究极纠结