◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
ssm集成时报的错误
在使用ssm框架整合时,可能会遇到以下错误信息:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.sxt.service.UserService cn.sxt.controller.UserController.userService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.sxt.dao.UserDao cn.sxt.service.impl.UserServiceImpl.userDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in file [D:workspace2my.metadata.me_tcatwebappsssmWEB-INFclassescnsxtdaoimplUserDaoImpl.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
翻译:
userdao初始化错误,需要属性“sqlsessionfactory”或“sqlsessiontemplate”。
错误原因:
从错误信息中可以看出,导致错误的原因是userdao在初始化时缺少了sqlsessionfactory或sqlsessiontemplate属性。
解决办法:
在userdaoimpl类中,确保创建了sqlsessionfactory或sqlsessiontemplate实例,并且在userdao的初始化方法中正确设置了这些属性。
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。