If you don't want any dependency on Spring's HATEOAS or javax.*
namespace, use ServletUriComponentsBuilder
to get URI of current request:
import org.springframework.web.util.UriComponentsBuilder;
ServletUriComponentsBuilder.fromCurrentRequest();
ServletUriComponentsBuilder.fromCurrentRequestUri();