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

本文介绍了解决新旧版本Hibernate配置问题的方法,并针对使用Spring框架时出现的HibernateTemplate过时错误提供了更新方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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


建议修改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


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

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

                给为

import org.springframework.orm.hibernate5.HibernateTemplate;
bingo!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值