【发布时间】:2018-03-06 13:28:47
【问题描述】:
我见过很多 Spring boot 的例子,其中我们声明了一个扩展 crudrepository 的接口并声明了 CRUUD 方法。在 Service CLass 中发布我们自动装配接口并从 Service 类调用 crud 方法。
既然我们没有在任何地方实现这个接口(它扩展了 CrudRepo 在例子 PersonRepo 中),怎么会出现 spring 实例呢? 例如:
interface PersonRepo extends CRUDRepository {
// method declaration
}
@Service
class PersonService{
@Autowire
PersonRepo perrepo;
void insert(){
perrepo.methodname();
}
}
【问题讨论】:
标签: spring spring-boot