用sessionFactory.getCurrentSession();方法会抛出No Session found for current thread异常
有没有大神解决一下啊,百度的方法都不靠谱,如果我把get方法改为openSession项目就可以运行。
只有这么点币了 只解救
肯定是你配置的问题,你看百度的配置相关方法,一个个排除一下
thread
配置thread
你看一下 是不是这里的问题
原因:发现一些bean无法获得当前session,需要把之前一些方法的事务从NOT_SUPPORT提升到required,readonly=true
例如:
<tx:method name="get*" read-only="true" propagation="REQUIRED"/><!--之前是NOT_SUPPORT-->
<tx:method name="find*" read-only="true" propagation="REQUIRED"/><!--之前是NOT_SUPPORT-->
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="remove*" propagation="REQUIRED"/>
<tx:method name="add*" propagation="REQUIRED"/>
<!--
默认其他方法都是
REQUIRED-->
<tx:method name="*"/>