报错: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);//保存权限数据Privilegemenu,menu1,menu2,menu3,menu4,menu5;//=====menu=newPrivilege("系统管理",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配置文件:
慕丝7291255
相关分类