第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Sping管理hibernate時的事務(wù)問題(No Hibernate Session bound to thread)

Sping管理hibernate時的事務(wù)問題(No Hibernate Session bound to thread)

手掌心 2019-04-19 16:11:45
報錯:Exceptioninthread"main"org.hibernate.HibernateException:NoHibernateSessionboundtothread,andconfigurationdoesnotallowcreationofnon-transactionalonehereatorg.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)atorg.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:685)atcn.itcast.oa.util.Installer.install(Installer.java:24)atcn.itcast.oa.util.Installer.main(Installer.java:88)報錯代碼片段:Java代碼:@ComponentpublicclassInstaller{@ResourceprivateSessionFactorysessionFactory;@Transactionalprivatevoidinstall(){Sessionsession=sessionFactory.getCurrentSession();//保存超級管理員賬戶Useruser=newUser();user.setLoginName("admin");user.setName("超級管理員");user.setPassword(DigestUtils.md5Hex("admin"));session.save(user);//保存權(quán)限數(shù)據(jù)Privilegemenu,menu1,menu2,menu3,menu4,menu5;//=====menu=newPrivilege("系統(tǒng)管理",null,null);menu1=newPrivilege("崗位管理","/role_list",menu);menu2=newPrivilege("部門管理","/department_list",menu);menu3=newPrivilege("用戶管理","/user_list",menu);session.save(menu);session.save(menu1);session.save(menu2);session.save(menu3);}publicstaticvoidmain(String[]args){ApplicationContextac=newClassPathXmlApplicationContext("applicationContext.xml");Installerinstaller=(Installer)ac.getBean("installer");installer.install();}}Spring配置文件:
查看完整描述

2 回答

?
躍然一笑

TA貢獻1826條經(jīng)驗 獲得超6個贊

報錯:Exceptioninthread"main"org.hibernate.HibernateException:NoHibernateSessionboundtothread,andconfigurationdoesnotallowcreationofnon-transactionalonehere
報錯很明顯了,然后你的評論問題為什么opensession可以?
推薦你2個帖子看一下SSH中使用getCurrentSession()獲得session
getCurrentSession與openSession()的區(qū)別,雖然寫的早了點和你用的配置不太相同,但hibernate的實現(xiàn)是一樣的。當(dāng)然如果還是不太明白的話,那就問問給你教材的人吧。。
                            
查看完整回答
反對 回復(fù) 2019-04-19
  • 2 回答
  • 0 關(guān)注
  • 320 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號