【问题标题】:I use spring 4+ hibernate 4 encounter following error:我使用 spring 4+ hibernate 4 遇到以下错误:
【发布时间】:2016-06-02 18:02:01
【问题描述】:

org.springframework.beans.factory.BeanCreationException: 错误 创建名为“studentController”的bean:注入自动装配 依赖失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:不能 自动装配字段:公共 edu.java.spring.dao.impl.StudentHibernateDaoImpl edu.java.spring.controller.StudentController.studentDAO;嵌套的 例外是 org.springframework.beans.factory.BeanCreationException: 创建名为“studentDao”的 bean 时出错:注入自动装配 依赖失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:不能 自动装配字段:公共 org.springframework.orm.hibernate3.LocalSessionFactoryBean edu.java.spring.dao.impl.StudentHibernateDaoImpl.sessionFactory; 嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException: 否 符合条件的 bean 类型 [org.springframework.orm.hibernate3.LocalSessionFactoryBean] 找到 依赖项:预计至少有 1 个符合自动装配条件的 bean 这种依赖的候选人。依赖注解: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

【问题讨论】:

  • 你能发布你的spring xml或配置类吗?

标签: spring hibernate


【解决方案1】:

如果没有关于你的配置或你的类的更多信息,有两种可能的解决方案:

  1. 您没有扫描包含该类的包
  2. @Autowired 没有使用 Spring 知道的任何内容进行注释,例如 @Repositoy@Service@Component

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-10
    • 2011-07-12
    • 2014-07-09
    • 2013-03-16
    相关资源
    最近更新 更多