For a REST API, in the controller I'm applying hateoas. When adding the part of Link in the methods, I get the follow error:
Cannot resolve constructor 'Link(String)'
In the pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
The code is as follows:
@GetMapping
public @ResponseBody ResponseEntity<List<UserResponseDTO>> get() {
// Retrieve users
List<UserResponseDTO> responseDTOS = new ArrayList<>();
List<User> users = userService.getUsers();
// Convert to responseDTOS
for (User user : users) {
UserResponseDTO userResponseDTO = new UserResponseDTO(user.getId(), user.getFirstName(), user.getLastName());
Link get = new Link("http://localhost:8081/user/").withRel("GET");
userResponseDTO.add(get);
responseDTOS.add(userResponseDTO);
}
return new ResponseEntity<>(responseDTOS, HttpStatus.OK);
}
Does anyone know how to solve this?