Judy1989
Judy1989

Reputation: 437

Accessing a Spring Data REST API With Feign

I am trying to consume a Rest CRUD API with Feign Client. I've added the HATEOAS dependency to the Client application.

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

And here is the Client Interface

@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);

}

But Here I still have "Candidate cannot be resolved to a Type" How can I do to read Candidate, which an Entity in the Rest Service, in the Rest Client ?

Upvotes: 0

Views: 790

Answers (1)

DavidX
DavidX

Reputation: 1319

It's a Java compiler error. The client needs Candidate.java imported on the client. It can be fixed with "Fix Project Setup" on the IDE, or adding the library to the classpath and importing the relevant package.

Upvotes: 1

Related Questions