Spring注释示例服务器加载时间显示错误

时间:2016-02-25 16:21:07

标签: spring

我是春天的新人我在eclipse luna做的弹簧注释示例同样在myeclipse中工作但没有在eclipse中工作

得到此错误可以帮助我

org.springframework.beans.factory.BeanCreationException:创建名为'studentController'的bean时出错:注入自动连接的依赖项失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装配字段:private com.vcs.service.StudentService com.vcs.controller.StudentController.studentService;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'studentServiceImpl'的bean时出错:注入自动连接的依赖项失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装配字段:private com.vcs.dao.StudentDao com.vcs.service.StudentServiceImpl.studentDao;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'studentdaoImpl'的bean时出错:注入自动连接的依赖项失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装配字段:private org.hibernate.SessionFactory com.vcs.dao.StudentdaoImpl.sessionFactory;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建在ServletContext资源[/WEB-INF/DispatcherServlet-servlet.xml]中定义名称为'sessionFactory'的bean时出错:init方法的调用失败;嵌套异常是java.lang.NoClassDefFoundError:org / hibernate / context / CurrentSessionContext     在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)

2 个答案:

答案 0 :(得分:0)

查看最后一个错误' java.lang.NoClassDefFoundError'它看起来好像你缺少一个包含CurrentSessionContext的hibernate依赖项(hibernate-core)。

答案 1 :(得分:0)

您正在获取org.hibernate.context.CurrentSessionContext的NoClassDefFoundError异常。

我的猜测是,在你的eclipse设置下,所需的依赖关系不在你的类路径中。

检查war war archive中的lib文件夹以获取eclipse构建。我假设它是WEB-INF存在的WAR存档。

我是否还可以建议您在代码块中格式化代码以便于阅读