Java 将crudepository接口扩展到基接口
如何将接口Java 将crudepository接口扩展到基接口,java,interface,spring-data-jpa,Java,Interface,Spring Data Jpa,如何将接口crudepository,MongoRepository,paging和sortingrepository扩展到BaseRepository?(如有可能) 我想有三个接口的访问方法 我试过: @SuppressWarnings("rawtypes") public interface BaseRepositoryDao<T, ID> extends CrudRepository, MongoRepository, PagingAndSortingRepos
crudepository
,MongoRepository
,paging和sortingrepository
扩展到BaseRepository
?(如有可能)
我想有三个接口的访问方法
我试过:
@SuppressWarnings("rawtypes")
public interface BaseRepositoryDao<T, ID> extends CrudRepository,
MongoRepository, PagingAndSortingRepository {
}
@SuppressWarnings(“rawtypes”)
公共接口BaseRepositoryDao扩展了CrudeRepository,
MongoRepository、Paging和SortingRepository{
}
我怎样才能做到这一点
编辑:
MongoRepository
已经扩展了PagingAndSortingRepository
A是crudepository
和PagingAndSortingRepository
,因此以下内容就足够了:
public interface BaseRepositoryDao<T, ID extends Serializable> extends MongoRepository<T, ID> {
}
公共接口BaseRepositoryDao扩展了MongoRepository{
}
那么问题是什么?这和我的答案有什么不同吗?@bot你的答案是非常错误的。还是有点错,,因为它忽略了类型约束。我想我可能是错的,但是你能详细说明一下它忽略了什么类型参数吗?MongoRespository
中的@botID
需要扩展可序列化的接口,因此扩展MongoRespository
的泛型接口必须具有相同的类型约束ID
。我不知道有这样的限制。在这种情况下,我确实站得住脚。