2023-09-03
package com.hh.util; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import java.io.IOException; import java.io.InputStream; /** * @author hh * @version 1.0 * @DATE 2023-09-03 15:16:50 */ public class SqlSessionFactoryUtil { private static SqlSessionFactory sqlSessionFactory; static { try { String resource = "mybatis-config.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); } catch (IOException e) { throw new RuntimeException(e); } } public static SqlSessionFactory getsqlSessionFactory(){ return sqlSessionFactory; } }
标签:SqlSessionFactoryUtil,sqlSessionFactory,ibatis,SqlSessionFactory,static,io,impor From: https://www.cnblogs.com/isDaHua/p/17675031.html