-
加载mybatis核心配置文件:
public class MyBatisDemo { public static void main(String[] args) throws IOException { /*加载mybatis核心配置文件,获取sqlsessionfactory*/ String resource = "org/mybatis/example/mybatis-config.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); SqlSession sqlSession = sqlSessionFactory.openSession(); List<User> users = sqlSession.selectList("test.selectAll"); System.out.println(users); sqlSession.close(); } }
String resource = "org/mybatis/example/mybatis-config.xml"; //此处配置文件地址、名称要与个人配置一致
配置MyBatis注意点
于 2022-12-18 19:36:53 首次发布
关键词由CSDN通过智能技术生成