RestTemplate template = new RestTemplate();
template.setUriTemplateHandler(new DefaultUriBuilderFactory("http://localhost:8080"));
template.getForObject("/users/{id}", String.class, 1);
template.getForObject("/users/1", String.class);
// following will works as above after this commit
template.getForObject(URI.create("/users/1"), String.class);
template.exchange(RequestEntity.method(HttpMethod.GET, "/users/{id}", 1).build(), String.class);
template.exchange(RequestEntity.method(HttpMethod.GET, "/users/1").build(), String.class);
// following will works as above after this commit
template.exchange(RequestEntity.method(HttpMethod.GET, URI.create("/users/1")).build(), String.class);
It will make Spring Boot TestRestTemplate
much more cleaner, save it from ubiquitous applyRootUriIfNecessary
https://github.com/spring-projects/spring-boot/blob/05a64ecb2ca237d963866665d3a0e7fd1920fee6/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java#L942-L948
Comment From: quaff
RestTemplate
is still relevant, could you review this PR? @rstoyanchev