我想在我的spring-boot应用程序中自定义基本存储库。看起来像:
基本界面:
@NoRepositoryBean
public interface MyRepository<T, ID> extends JpaRepositoryImplementation<T, ID>, QuerydslPredicateExecutor<T> {
// ... customized methods ...
}
基本实现:
@NoRepositoryBean
public class MyRepositoryImpl<T, ID extends Serializable> extends QuerydslJpaRepository<T, ID> implements MyRepository<T, ID> {
// constructor
public MyRepositoryImpl(JpaEntityInformation<T, ID> entityInformation, EntityManager entityManager) {
super(entityInformation, entityManager);
}
// ... customized methods implementations ...
}
如您所见,我想使用Querydsl。
在spring-data-jpa中,我可以找到的唯一同时实现JpaRepository
和QuerydslPredicateExecutor
接口的类只有QuerydslJpaRepository
,但是是@Deprecated
。
如果我的基本存储库(MyRepositoryImpl.class
)无法从QuerydslJpaRepository
继承,我还有其他选择吗?
另一个问题: 如果我不关心@Deprecated,是否可以在Spring-Boot环境中直接配置@EnableJpaRepositories?
@Configuration
@EnableJpaRepositories(repositoryBaseClass = MyRepositoryImpl.class)
public class PersistenceConfig {
// ...
}
我担心这会破坏Spring-Boot的许多内置基础结构,因此我需要自己重新配置它们(例如transactionManager
或其他bean)。
spring-boot是否提供 customer 允许我仅配置属性值,而不会影响所有其他自动配置行为。