遇到问题:
//xml乱码解决新增字符集
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
mybatis工具类
public class MybatisUtils {
private static SqlSessionFactory sqlSessionFactory;
static {
try {
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
public static SqlSession getSqlSession(){
return sqlSessionFactory.openSession();
}
}
//增删改需要提交事务
sqlSession.commit();