AnnotationConfiguration继承自Configuration,这里以AnnotationConfiguration为例:

new AnnotationConfiguration().configure().buildSessionFactory();

AnnotationConfiguration().configure()会默认找src下的hibernate.cfg.xml,读取配置信息。
* 最主要的是数据库连接信息,帮你做出连接池。SessionFactory代表着跟数据库的连接。
* configure()有个重载方法 configure(String resource)可以指定配置文件文件名;如果配置文件叫hibernate.xml,
* 就configure("hibernate.xml"),默认去classpath下找配置文件。

 

 欢迎关注个人公众号一起交流学习:

hibernate核心开发接口_Configuration

相关文章:

  • 2021-08-12
  • 2021-12-22
  • 2021-08-14
  • 2021-08-26
  • 2021-09-03
  • 2021-11-30
  • 2022-12-23
  • 2021-06-27
猜你喜欢
  • 2022-01-14
  • 2022-02-02
  • 2021-10-02
  • 2021-11-18
  • 2021-05-22
  • 2022-12-23
  • 2021-05-17
相关资源
相似解决方案