【发布时间】:2020-03-26 16:33:56
【问题描述】:
使用 Spring Data,您可以为给定实体创建一个存储库:
@Repository
public interface MyRepo extends CrudRepository<MyEntity, Long> {...}
但是,如果您有很多不与特定实体绑定的自定义查询呢?
以下都不起作用:
@Repository
public interface MyRepo {...}
@Repository
public interface MyRepo extends CrudRepository {...}
@Component
public interface MyRepo extends Repository {...}
等等..
基本上我想要的是能够将一些@Querys 封装到一个可注入的类或接口中。
【问题讨论】:
-
认为link 会帮助你。
-
不确定该链接是如何关联的。
标签: spring spring-boot spring-data-jpa spring-data