一方面,我刚刚将 spring-data-rest-webmc 的版本更新为我的服务器的最新 2.0.0.RC1 版本。在此版本中,json 格式更改为 HAL 格式。
另一方面,我有一个使用 0.9.0.RELEASE 版本的 spring-hateoas 库的客户端。在这个客户端中,我使用 RestTemplate 从我的服务器获取资源,如下所示:
AuthorResource authorResource = restTemplate.getForObject(BASE_URL+"authors/"+ authorId, AuthorResource.class);
AuthorResource 类扩展了 ResourceSupport。
现在,我有这个错误:
Nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "_links" (class org.example.hateoas.AuthorResource)
如何配置我的客户端以支持这种新格式?我试试
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
但它不起作用。
谢谢你的帮助。