Hibernate新手常见问题org.hibernate.service.spi.ServiceException: Unable to create requested service

org.hibernate.service.spi.ServiceException: Unable to create requested service
[org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
错误详情:

Hibernate新手常见问题org.hibernate.service.spi.ServiceException: Unable to create requested service


首先看到jdbcEnvironment肯定得先考虑jdbc配置的问题,驱动?配置文件?
第一步:
    检查数据库的驱动,例如:mysql-connector-java-5.1.45-bin.jar
第二步:
    检查xml配置文件--5个必要
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  <property name="hibernate.connection.url">jdbc:mysql:///hibernate</property>
  <property name="hibernate.connection.username">root</property>
  <property name="hibernate.connection.password">123</property>
  
  <!-- 数据库的方言 -->
  <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

第三步:
    换成新版方言:org.hibernate.dialect.MySQL5Dialect

第四步:
    在url后加上?serverTimeZone=UTC,例:<property name="hibernate.connection.url">jdbc:mysql:///hibernate?serverTimeZone=UTC</property>

以上步骤每完成一步应去测试一下,因为你可能是其中某部分出了问题,改回来即可