首页 > 编程知识 正文

spring redis 集成,hibernate框架搭建

时间:2023-05-04 14:06:25 阅读:131767 作者:2453

basedaopackagecom.CHB.spring _ hibernate.Dao; import javax.annotation.resource; import org.hibernate.Session; importorg.spring framework.ORM.hibernate5. hibernate template; publicclassbasedao { privatehibernatetemplatehibernatetemplate; @ resourcepublicvoidsethibernatetemplate this.hibernate template=hibernate template } } protectedsessiongetsession ((returnhibernatetemplate.getsession factory ) ).getCurrentSession ); } 添加测试@ org.JUnit.testpublicvoidtesthibernateadd ((applicationcontextcontext=newclasspathxmlapplicationcontext (' clasplationt oupDaogroupDao=(IgroupDao ) context.getbean ) (grouphibernatedao ); Iuserdaouserdao=(Iuserdao )上下文. get bean (userhibernatedao ); 组组=new组(; group.setGroupName (信息类); 组道.添加组(组; 系统. out.println (group; useruser=newuser('CHB ',' 123456 ',' chbtmp ' ); userdao.add(user,group.getId ) ); (测试错误) org.spring framework.ORM.hibernate5. hibernate template不可用。 注rqdnhtorg.spring framework.beans.factory.beancreationexception : errorcreatingbeanwithname ' grouphibernatedao ' 336660 rame work.beans.factory.nosuchbeandefinitionexception 3360 noqualifyingbeanoftype ' org.spp org.hibernate template ' avaivion ifiesasautowirecandidate.dependency annotations 3360 { } caused by : org.spring framework.beans.factory.nosuchbeandefinitionexception 3360 noqualifyingbeanoftype ' org.spring rrrion t least1beanwhichqualifiesasautowirecandidate.dependency annotations 3360 { }注rqdnht, 添加到SpringBean.xml、HibernateTemplate以及session factory.bean id=' hibernate template ' class=' org.spring framework

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。