CrudRepository接口-找不到bean

时间:2020-06-30 14:59:42

标签: java spring-boot spring-data-jpa spring-data-mongodb

我正在这样使用CrudRepository

@Repository
public interface Reports extends CrudRepository<Report, UUID> {

}

当我试图注入Reports存储库来像这样服务

@Component
@AllArgsConstructor
class ReportsService {

    private final Reports reports;

// ...
}

我要

Parameter 0 of constructor in ReportsService required a bean of type 'Reports' that could not be found.
Consider defining a bean of type Reports in your configuration.

我的gradle依赖文件看起来像这样

    implementation(
            'org.flywaydb:flyway-core',
            'org.springframework.boot:spring-boot-starter-data-jpa',
            'com.vladmihalcea:hibernate-types-52:2.3.3',
            'org.springframework.boot:spring-boot-starter',
            'org.springframework.boot:spring-boot-starter-web',
            'com.google.code.gson:gson:2.8.5',
            'com.opencsv:opencsv:4.1',
            'org.springframework.data:spring-data-mongodb',
            'org.springframework.boot:spring-boot-starter-data-jdbc'
    )

什么配置错误?

1 个答案:

答案 0 :(得分:0)

好的,因此解决方案是摆脱org.springframework.data:spring-data-mongodb并改用其他方法,在我的情况下,我使用mongodb Morphia。

相关问题