Вот фрагмент моего кода, в котором я использую RestClient. для выполнения HTTP-запросов:
Код: Выделить всё
@RestController
@RequestMapping("weather")
public class WeatherController {
@Autowired
private final RestClient restClient;
@GetMapping("{countryCode}")
public Weather getWeather(@PathVariable String countryCode){
return this.restClient.get()
.uri("{countryCode}", countryCode)
.retrieve()
.body(Weather.class);
}
}
@Configuration
public class ClientConfig {
@Bean
public RestClient weatherServiceClient(@Value("${weather.service.url}") String baseUrl) {
return RestClient.builder()
.baseUrl(baseUrl)
.build();
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... configurat
Мобильная версия