繁体   English   中英

CrudRepository 接口 - 找不到 bean

[英]CrudRepository interface - bean not found

我正在像这样使用 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'
    )

什么可能配置错误?

好的,所以解决方案是摆脱org.springframework.data:spring-data-mongodb并使用不同的东西,在我的情况下,我使用了 mongodb Morphia。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM