Spring+SpringMVC+Hibernate4搭建

参考文章:

1、http://blog.csdn.net/yannanying/article/details/44288179#comments

      好像有点小问题,调用其他方法的话会报sessionFacotory.getCurrentSession() 每次都获取不到 Session,原因:

spring-hibernate.xml 里面
<aop:config>
<aop:pointcut id="transactionPointcut" expression="execution(* com.phn.service..*Impl.*(..))" />
<aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice" />
</aop:config>

监控的是service方法,未监控到实现类里面,改为:* com.phn.service.impl.*.*(..) 或者是* com.phn.service.impl.*Impl.*(..),描述语句为:什么包下的什么类的什么方法。

@Transactional声明的方法执行时,Spring的TransactionManager会自动Open Sesion,自动开启事务,并且将此Sesion绑定到SpringSessionContext。如果事务没配对,就会出现上述问题。

关于hibernate的session问题:使用getCurrentSession还是openSession(),查看文章:http://blog.csdn.net/irelandken/article/details/7193123

2、http://blog.csdn.net/js931178805/article/details/39642743?utm_source=tuicool&utm_medium=referral

3 这篇写的比较详细,而且有解释:http://kyfxbl.iteye.com/blog/1634355 c

参考的是张开涛的:http://kyfxbl.iteye.com/blog/1634355

问题:点击打开链接

百度的时候查到的,感觉博主整理的不错,放到这里随时查看:http://blog.csdn.net/fengshizty/article/category/2854337

Spring4 MVC Hibernate4集成:http://www.cnblogs.com/leiOOlei/p/3727859.html#top

全注解方式搭建:点击打开链接


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值