当同一域类型存在两个存储库接口时,Spring Data Rest公开RepositoryRestResource会随机失败

当同一域类型存在两个存储库接口时,Spring Data Rest公开RepositoryRestResource会随机失败,spring,spring-data-rest,Spring,Spring Data Rest,Hello堆栈溢出 我正在使用SpringDataJPA和SpringDataREST为自己创建一个演示应用程序。我有两个存储库接口: interface PersonRepository : PagingAndSortingRepository<Person, Long> @RepositoryRestResource(path = "people", collectionResourceRel = "people", exported = true) interface Peo

Hello堆栈溢出

我正在使用SpringDataJPA和SpringDataREST为自己创建一个演示应用程序。我有两个存储库接口:

interface PersonRepository : PagingAndSortingRepository<Person, Long>

@RepositoryRestResource(path = "people", collectionResourceRel = "people", exported = true)
interface PeopleRepository : PagingAndSortingRepository<Person, Long>
接口PersonRepository:PagingAndSortingRepository
@RepositoryRestResource(path=“people”,collectionResourceRel=“people”,exported=true)
接口人员存储库:分页和排序存储库
我将repositoryDetectionStrategy更改为RepositoryDetectionStrategys.ANNOTATED

我为personRepository创建了一个自制的RestController,用于peopleRepository我希望它由spring创建,并在localhost:8080/由hateos公开

问题

  • 只是随机暴露peopleRepository(根本不工作)
调试后,我可以肯定地说,RepositoryRestMVCCConfiguration的Bean存储库是问题的原因

org.springframework.data.repository.support.Repositories的方法populateRepositoryFactoryInformation覆盖了所有存储库,因为对于同一个类,我有两个存储库,内部map.put会覆盖我想要的行为,具体取决于哪个bean首先出现


那么这是一个bug还是spring不支持使用spring data rest的多个存储库接口,还是我对设置有误?

遗憾的是,
SpringData
似乎不能很好地处理这种情况(我使用的是spring boot 1.5.8,当时我发现了与您相同的问题…我试图升级我的spring版本,看看这是否已修复,但我开始遇到其他编译/部署问题。因此我放弃了这个想法…)

您可以通过以下链接获得更多信息:


你找到解决办法了吗?我也有同样的问题。。。