habuma / spring-in-action-5-samples

Home for example code from Spring in Action 5.
Apache License 2.0
1.21k stars 1.04k forks source link

[Ch 06] SpringDataRestConfiguration #93

Closed allut closed 4 years ago

allut commented 4 years ago

Because of the migration to the Spring HATEOAS 1.0, the code in SpringDataRestConfiguration class doesn't work (most of the Representation models have been renamed, and their methods also have undergone some changes). I'm struggling with writing working code. Could anyone provide a working version of SpringDataRestConfiguration?

allut commented 4 years ago

I've managed to refactor the code. The working version should look as follows:

@Bean public RepresentationModelProcessor<PagedModel<EntityModel<Taco>>> tacoProcessor(EntityLinks links) { return new RepresentationModelProcessor<PagedModel<EntityModel<Taco>>>() { @Override public PagedModel<EntityModel<Taco>> process(PagedModel<EntityModel<Taco>> resource) { resource.add(links.linkFor(Taco.class).slash("recent").withRel("recents")); return resource; } }; }