在项目的src下新建一个.xml 名称为hibernate.cfg.xml
代码如下(我的是mysql+hibernate5.3)版本不同 写法都不同 看看你用的都是啥版本
注:其中我的数据库是hibernate 账号root 密码为空 你要改成你自己的
粗体部分写你自己的实体类的映射文件地址
/p>
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
com.mysql.cj.jdbc.Driver
jdbc:mysql://localhost:3306/hibernate?useSSL=false&serverTimezone=UTC
root
true
true
update
org.hibernate.dialect.MySQL8Dialect
thread