可能是新旧版本的hibernate配置问题

idea:(hibernate)org.hibernate.service.spi.ServiceException: Unable to create requested service

建议修改hibernate.hbm.xml配置信息

<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">
    jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8&amp;serverTimezone=UTC

</property>
<property name="connection.username">conn</property>
<property name="connection.password"></property>
<!-- 指定数据库的方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>

2.使用spring框架报错。

'org.springframework.orm.hibernate3.HibernateTemplate' is deprecated less... (Ctrl+F1) 

This inspection reports where deprecated code is used in the specified inspection scope

idea:(hibernate)org.hibernate.service.spi.ServiceException: Unable to create requested service

报错原因:hibernate3以后修改了HibernateTemplate方法,配置的是hibernate4或者5,就不兼容;网上一般都说是抛弃了,然而你看了我的修改方法,就知道我为什么这么说了。

修改方案:将import org.springframework.orm.hibernate3.HibernateTemplate;

                给为

import org.springframework.orm.hibernate5.HibernateTemplate;
bingo!

相关文章: