小编Nao*_*id2的帖子

com.XXX 中的字段需要一个无法找到的类型的 bean

我正在研究 Spring over Hibernate 项目,但我才刚刚开始。我正在尝试使用 SpringBootApplication 向 MsSql 写入一些 LogEntries 对象。我有一些不同的包:

在此输入图像描述

这是课程:

LogEntryFacadeImpl.class :

package com.tradingSystem.dataAccess;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.tradingSystem.entity.LogEntry;

@Service
public class LogEntryFacadeImpl implements LogEntryFacade{
    @Autowired
    private LogEntryDAO logEntryDao;

    @Transactional
    @Override
    public Long addLogEntry(LogEntry log) {
        return this.logEntryDao.save(log).getId();
    }

    @Override
    public LogEntry getLogEntry(Long logId) {
        return this.logEntryDao.findOne(logId);
    }
}
Run Code Online (Sandbox Code Playgroud)

LogEntryDAO.类:

package com.tradingSystem.dataAccess;

import org.springframework.data.jpa.repository.JpaRepository;
import com.tradingSystem.entity.LogEntry;

public interface LogEntryDAO extends JpaRepository<LogEntry, Long> {

}
Run Code Online (Sandbox Code Playgroud)

我使用这个类作为测试器:

测试应用程序.类:

package com.testings;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate

5
推荐指数
1
解决办法
7973
查看次数

标签 统计

hibernate ×1

java ×1

spring ×1