java - Bean创建异常, Autowiring 依赖注入(inject)失败

标签 java spring hibernate spring-mvc

我在我的应用程序中使用 spring hibernate。我使用了所有必需的 jar 文件,但仍然收到 Bean 创建异常,内容如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'voteController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.mindtree.service.VoteService com.mindtree.controller.VoteController.voteService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'voteServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.mindtree.dao.VoteDao com.mindtree.serviceImpl.VoteServiceImpl.voteDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'voteDaoImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.orm.hibernate3.HibernateTemplate com.mindtree.daoImpl.VoteDaoImpl.hibernateTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool

最佳答案

在Java中,从最后一行读取堆栈跟踪,这将是问题的根本原因。如果您通过在类路径中添加相应的 jar 文件来修复 java.lang.NoClassDefFoundError,那么它将正常工作。

关于java - Bean创建异常, Autowiring 依赖注入(inject)失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30860320/

相关文章:

java - 将 cellpadding 添加到 Java JTable

java - 通过 ExecutorService 在 Thread 中所做的更改在执行后未反射(reflect)出来

Java Spring : Attribute 'time-unit' is not allowed to appear in element 'int:poller'

json - Jackson JSON、Spring MVC 4.2 和 Hibernate JPA 问题的无限递归

java - 无法在 Android 中以 AM、PM 格式正确显示时间

java - 使用 java 小程序查看 .doc 文件

java - 替换多次出现的字符

java - Spring Data JPA xml 配置 : "Table not found" with create-drop

java - 使用 HibernateProxyTypeAdapter for Gson 后出现 org.hibernate.LazyInitializationException

java - JPA/Hibernate 批量(批量)插入