mybatis_15_在 SqlSessionFactoryBuilder.build() 方法中传入属性值

查阅SqlSessionFactoryBuilder.java中重载函数build的定义中,存在支持传入Properties的定义

 

 使用参考:

String resource = "mybatis-config2.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
String url = "jdbc:postgresql://172.16.x.x:5432/database_name";
//定义properties属性url
Properties properties = new Properties();
properties.setProperty("url", url);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream, properties);

  

posted @ 2022-10-18 15:17  留白*  阅读(51)  评论(0编辑  收藏  举报