Can I make a custom controller mirror the formatting of Spring-Data-Rest / Spring-Hateoas generated classes?

I’ve found a way to imitate the behavior of Spring Data Rest completely. The trick lies in using a combination of the PagedResourcesAssembler and an argument-injected instance of PersistentEntityResourceAssembler. Simply define your controller as follows… @RepositoryRestController @RequestMapping(“…”) public class ThingController { @Autowired private PagedResourcesAssembler pagedResourcesAssembler; @SuppressWarnings(“unchecked”) // optional – ignores warning on return statement below… … Read more

How to correctly use PagedResourcesAssembler from Spring Data?

You seem to have already found out about the proper way to use but I’d like to go into some of the details here a bit for others to find as well. I went into similar detail about PagedResourceAssembler in this answer. Representation models Spring HATEOAS ships with a variety of base classes for representation … Read more

Enable HAL serialization in Spring Boot for custom controller method

There’s a lot of aspects here: I doubt that the collection resource at /transactions really returns an individual transaction as you described. Those representations are returned for item resources. If TransactionRepository already is a PageableAndSortingRepository the collection resource can be tweaked by expanding the URI template exposed in the API root for the link named … Read more

tech