Loading

sqlSessionFactory.openSession(true)

public class MybatisUtils {
    private static SqlSessionFactory sqlSessionFactory;
    static{
        try {
            String resources="mybatis-config.xml";
            InputStream inputStream = Resources.getResourceAsStream(resources);
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static SqlSession getSqlSessionFactory() {
      //在这里设置为true   以后的增删改就不用提交事务  默认为false
        return sqlSessionFactory.openSession(true);
    }
}    

 

posted @ 2020-03-19 11:41  Rzk  阅读(2184)  评论(0编辑  收藏  举报