Spring MVC:找不到类型为 [org.hibernate.SessionFactory]

我得到一个很长的嵌套异常,最后一个是:


Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.hibernate.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

at ...

这是我的 DAO


import org.hibernate.SessionFactory;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Repository;

import org.springframework.transaction.annotation.Transactional;


import ar.edu.itba.paw.FileUploadDao;

import ar.edu.itba.paw.models.UploadFile;


@Repository

public class FileUploadDAOImpl implements FileUploadDao {

    @Autowired

    private SessionFactory sessionFactory;


    public FileUploadDAOImpl() {

    }


    public FileUploadDAOImpl(SessionFactory sessionFactory) {

        this.sessionFactory = sessionFactory;

    }


    @Transactional

    public void save(UploadFile uploadFile) {

        sessionFactory.getCurrentSession().save(uploadFile);

    }

}

这是我在 DAO 所在的持久性文件夹中的 pom.xml。


<?xml version="1.0"?>

<project

    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"

    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>

    <parent>

        <groupId>ar.edu.itba.paw</groupId>

        <artifactId>paw2018b</artifactId>

        <version>1.0-SNAPSHOT</version>

    </parent>

    <groupId>ar.edu.itba.paw</groupId>

    <artifactId>interfaces</artifactId>

    <version>1.0-SNAPSHOT</version>

    <name>interfaces</name>

    <url>http://maven.apache.org</url>

    <properties>


繁花不似锦
浏览 310回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java