java - CrudRepository 接口 - 找不到 bean
问题描述
我正在像这样使用 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。
推荐阅读
- typescript - 带有 Typescript 和 ES6 代理的 MongoModel 类
- json - 如何在 postgres 中导入 json 文件
- woocommerce - WooCommerce:删除单个产品的面包屑不起作用
- angular - 复选框在边缘浏览器中返回 true,因为 chrome 按预期工作
- android - 我想将数据从片段发送到片段
- postgresql - 使用 Postgresql 进行多语言全文搜索
- python - 使用python替换文件中最后2次出现的特定单词
- angular - 登录restangular后如何设置令牌?
- git - git 和 heroku 集成
- docker - 重置 Kubernetes 集群