Spring 数据项目 - Couchbase 集成
Spring Data Project - Couchbase Integration
我通过 Spring
阅读了以下使用 couchbase db 的教程
http://projects.spring.io/spring-data-couchbase/#quick-start
我看到下面的自动接线正在使用 class。 UserRepository 是一个接口。我假设应该有一个实现此接口并公开一个 bean 的实现。我没有看到任何 class 实现此接口或作为 bean 公开。是否可以帮助解释这是如何工作的?
@Autowired
public MyService(UserRepository userRepository) {
this.userRepository = userRepository;
}
Spring-Data 项目的目的是在您仅定义接口时在运行时为您创建此类实现。
它将检查您为通过反射扫描配置的包,并在其中发现 xxRepository
接口,此时它将使用特定商店 Spring 提供的基础 class ] 您选择的数据子项目(这里是 Couchbase)将 xxRepository
的具体实现编织在一起并注入它。
我通过 Spring
阅读了以下使用 couchbase db 的教程http://projects.spring.io/spring-data-couchbase/#quick-start
我看到下面的自动接线正在使用 class。 UserRepository 是一个接口。我假设应该有一个实现此接口并公开一个 bean 的实现。我没有看到任何 class 实现此接口或作为 bean 公开。是否可以帮助解释这是如何工作的?
@Autowired
public MyService(UserRepository userRepository) {
this.userRepository = userRepository;
}
Spring-Data 项目的目的是在您仅定义接口时在运行时为您创建此类实现。
它将检查您为通过反射扫描配置的包,并在其中发现 xxRepository
接口,此时它将使用特定商店 Spring 提供的基础 class ] 您选择的数据子项目(这里是 Couchbase)将 xxRepository
的具体实现编织在一起并注入它。