Java Spring Data Rest ничего не возвращает при работе с клиентом Feign на Pageable - PullRequest
0 голосов
/ 24 марта 2020

У меня есть репозиторий Spring Data Rest, который находит людей по идентификатору или городу, используя Pageable:

@RepositoryRestResource(collectionResourceRel = "persons", path = "persons")
public interface PersonRepository extends PagingAndSortingRepository<Person, Integer> {

    Person findById(@Param("id") String id);

    Page<Person> findByCity(@Param("city") String city, Pageable pageable);
}

Вот клиент Feign, который будет вызывать вышеуказанные конечные точки:

@FeignClient(name = "client", url = "https://abcd.com/myservice", configuration = FeignConfiguration.class)
public interface PersonFeignClient {

    @GetMapping(value = "/persons/search/findById?id={id}")
    Person getPeopleById(@PathVariable String id);

    @GetMapping(value = "/persons/search/findByCity?city={city}&page={page}&size={size}")
    Resources<Person> getPeopleByCity(@PathVariable String city, 
                                      @PathVariable String page,
                                      @PathVariable String size);
}

И в одном из моих занятий я вызываю описанные выше методы симуляции клиента. Мне удалось получить person по идентификатору, но возвращаемое ниже resourcesPerson не содержит никаких данных, и не было выдано никаких исключений, интересно, это потому, что я использовал Pageable. Я хотел бы знать, как получить данные для постраничного ввода с клиентом Feign. Спасибо.

     PersonFeignClient personFeignClient;
     Person person = personFeignClient.getPeopleById("1"); // this is fine

     Resources<Person> resourcesPerson = 
       personFeignClient.getPeopleByCity("duke", "0", "20"); // nothing returned

Spring Boot основной класс:

 @EnableFeignClients
 @EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
 @SpringBootApplication
 public class MyApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyApplication .class, args);
 }
}

И мой пом. xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
    <groupId>io.github.openfeign</groupId>
    <artifactId>feign-httpclient</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
...