Quarkus using Rest Client,解释了如何使用 MicroProfile REST Client。对于基本 URL application.properties 可以使用。
org.acme.restclient.CountriesService/mp-rest/url=https://restcountries.eu/rest #
Run Code Online (Sandbox Code Playgroud)
使用上述方法,不能有动态基本 URL。
能够通过使用 RestClientBuilder 来实现它,如MicroProfile Rest Client 中所述。这种方法的缺点是没有自动协商功能。
SimpleGetApi simpleGetApi = RestClientBuilder.newBuilder().baseUri(getApplicationUri()).build(SimpleGetApi.class);
Run Code Online (Sandbox Code Playgroud)
有没有其他或更好的方法来实现这一目标?谢谢。