spring整合hibernate时报错:org.hibernte.engine.transaction.spi.transactioncontext
错误提示:Caused by:java.lang.ClassNotFoundException: org.hibernte.engine.transaction.spi.transactioncontext
本人用的hibernate版本为5.2.5,spring为4.6.1.
在applicationContext.xml中错误配置:
<!--3. 配置hibernate的sessionfactory实例 ,通过spring提供的LocalSessionFactoryBean类进行配置-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<!-- 引入数据源 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 引入hibernate的配置文件 -->
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
<!-- hibernate中用xml配置的整合
引入bean的映射
<property name="mappingLocations" value="classpath:*.hbm.xml"></property>
-->
<!-- hibernate注解配置的整合
此处要用annotatedClasses属性才能生效,而不能用packageToscan属性。
-->
<property name="annotatedClasses">
<list>
<value>com.entity.Account</value>
<value>com.entity.Book</value>
</list>
</property>
</bean>
<!--4. 配置spring的声明事务管理 -->
<!-- 4.1 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<!-- 加入hibernate的sessionFactory实例 -->
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 4.2 配置事务属性,需要事务管理器 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<!-- 其他的方法使用默认值 -->
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<!-- 4.3 配置事务切点,并把切点和事务属性关联起来 -->
<aop:config>
<aop:pointcut expression="execution(* com.service.*.*(..))"
id="txPointcut"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
</aop:config>
解决办法:hibernate是5.0版本,而spring是4.0版本。5.0版本的hibernate中的相应包中把那个类给取消了。而在spring中配置时,我们最多只能配置到hibernate4,所以就出现了上述问题。
解决很简单,去网上下载hibernate4.0版本的hibernate-core-4.3.8.Final.jar,用这个文件替换中5.0中的那个。现在再运行,就能正常工作了
spring整合hibernate时报错:org.hibernte.engine.transaction.spi.transactioncontext的更多相关文章
- Spring整合Hibernate报错:annotatedClasses is not writable or has an invalid setter method
Spring 整合Hibernate时报错: org.springframework.beans.factory.BeanCreationException: Error creating bean ...
- Spring整合Redis时报错:java.util.NoSuchElementException: Unable to validate object
我在Spring整合Redis时报错,我是犯了一个很低级的错误! 我设置了Redis的访问密码,在Spring的配置文件却没有配置密码这一项,配置上密码后,终于不报错了!
- 解决Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext
我使用的是5.2.8的hibernate的jar包,运行的时候却报错Could not open Hibernate Session for transaction; nested exception ...
- 解决Exception:Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext
原因是配置文件中 <bean id="transactionManager" class="org.springframework.orm.hibernate4.H ...
- Spring整合Hibernate与Struts
整合S2SH 一.导入jar包 Spring jar包 Hibernate jar包 Struts2 jar包 以上就是整合需要的所有jar包,当然其中有重复的包,(对比之后去掉版本低的就可以了,还有 ...
- 【Java EE 学习 53】【Spring学习第五天】【Spring整合Hibernate】【Spring整合Hibernate、Struts2】【问题:整合hibernate之后事务不能回滚】
一.Spring整合Hibernate 1.如果一个DAO 类继承了HibernateDaoSupport,只需要在spring配置文件中注入SessionFactory就可以了:如果一个DAO类没有 ...
- spring整合hibernate
spring整合hibernate包括三部分:hibernate的配置.hibernate核心对象交给spring管理.事务由AOP控制 好处: 由java代码进行配置,摆脱硬编码,连接数据库等信息更 ...
- 使用Spring整合Hibernate,并实现对数据表的增、删、改、查的功能
1.1 问题 使用Spring整合Hibernate,并实现资费表的增.删.改.查. 1.2 方案 Spring整合Hibernate的步骤: 1.3 步骤 实现此案例需要按照如下步骤进行. 采用的环 ...
- 启动spring boot项目时报错:java.lang.ClassNotFoundException: javax.servlet.Filter
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...
随机推荐
- MySQL Proxy和 Amoeba 工作机制浅析
MySQL Proxy处于客户端应用程序和MySQL服务器之间,通过截断.改变并转发客户端和后端数据库之间的通信来实现其功能,这和WinGate 之类的网络代理服务器的基本思想是一样的.代理服务器是和 ...
- 选题博客:北航iCourse课程信息平台
1. 用户调查 在选题的时候,我们面向北航所有本科在读本科生,发布了<北航信息平台用户调查>.此次问卷调查共回收有效问卷95份. 1.1 功能需求调查 调查其中一项是让同学们对平台功能进行 ...
- centos下部署jenkins
本文摘抄自:https://www.cnblogs.com/edward2013/p/5284503.html ,请支持原版! 1. 安装JDK 1 yum -y install java 2.安装 ...
- Factorials 阶乘(思维)
Description N 的阶乘写作N!表示小于等于N的所有正整数的乘积.阶乘会很快的变大,如13!就必须用32位整数类型来存储,70!即使用浮点数也存不下了.你的任务是 找到阶乘最后面的非零位.举 ...
- PSP1130
PSP时间图: 类型 任务 开始时间 结束时间 净时间 中断时间 日期 开会 开会 16:17 16:50 33 0 20171027 开会 开会 17:00 17:22 22 0 20171028 ...
- HDU 5183 Negative and Positive (NP) 前缀和+哈希
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5183 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- 严重: Failed to destroy end point associated with ProtocolHandler ["http-nio-8080"] java.lang.NullPointer
刚接触servlet类,按照课本的方法使用eclipse新建了一个servlet类. 新建完成后,在web.xml里面进行注册 这时候就会报错了. 五月 07, 2016 11:23:28 上午 or ...
- 如何改变placeholder的颜色
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */ color: #f00; } ::-moz-placeholder { /* Mozilla Fir ...
- (转自大富翁)LockType 属性
指示编辑过程中对记录使用的锁定类型. 设置和返回值 设置或返回以下某个 LockTypeEnum 的值. 常量 说明 adLockReadOnly 默认值,只读.无法更改数据. adLockPessi ...
- 在DbGrid中,不按下Ctrl,单击鼠标如何实现多选?谢谢
解决方案 » 有了dbgrid1.options.dgmultiselect:=true;必须按下Ctrl键,才能实现多选, 修改源代码,把以下内容if Select and (ssShift i ...