对于hibernate 5.X hibernate.cfg.xml 需要这么写 注意MySQL5Dialect中有个5
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false</property>
<property name="connection.username">root</property>
<property name="connection.password">yanxin</property>
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<mapping resource="Students.hbm.xml"/>
</session-factory>
</hibernate-configuration>