使用 Feign 访问 Spring 数据 REST API

Accessing a Spring Data REST API With Feign

我正在尝试使用 Feign Client 使用 Rest CRUD API。 我已将 HATEOAS 依赖项添加到客户端应用程序。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>

这是客户端界面

@FeignClient(name="core-service")
@RibbonClient(name="core-service")
public interface VoteClient {

    @RequestMapping(method = RequestMethod.GET, path = "/candidates")
    Resources<Candidate> getCandidates();

    @RequestMapping(method = RequestMethod.GET, path = "/candidates/{id}")
    Resource<Candidate> getCandidate(@PathVariable("id") long id);

}

但是我这里还有"Candidate cannot be resolved to a Type" 如何在 Rest Client 中读取 Rest Service 中的实体 Candidate?

这是一个 Java 编译器错误。客户端需要在客户端导入 Candidate.java。可以在 IDE 上用 "Fix Project Setup" 修复,或者将库添加到类路径并导入相关包。