-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Support property placeholders in url attribute of @HttpExchange #28492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is still not working for me: // using spring boot 3.0.0 and framework 6.0.2
@SpringBootApplication
public class HttpInterfaceApplication {
public static void main(String[] args) {
SpringApplication.run(HttpInterfaceApplication.class, args);
}
@Bean
ApplicationListener<ApplicationReadyEvent> ready(GoogleClient googleClient) {
return event -> {
String googlePage = googleClient.getGooglePage();
System.out.println(googlePage);
};
}
@Bean
GoogleClient googleClient(HttpServiceProxyFactory factory) {
return factory.createClient(GoogleClient.class);
}
@Bean
HttpServiceProxyFactory getHttpServiceProxyFactory(WebClient.Builder builder) {
return HttpServiceProxyFactory.builder()
.clientAdapter(WebClientAdapter.forClient(builder.build())).build();
}
}
@HttpExchange(url = "${google.url}")
interface GoogleClient {
@GetExchange
String getGooglePage();
} Error:
When I use the url directly it works fine |
I stumbled in the same issue, and found out perhaps a clue to clarify if the URL field considers This error indicates that the application properties with placeholders are not considered at all: If you try, it just considers it a path: (like when you call @HttpExchange(url = "{httpbin}") // I chose a single name here, because if we try to simply remove the braces and add the $ back, it still doesn't work, but it's easy enough to use to test.
interface HttpBinClient {
@GetExchange("/anything")
fun anything(@PathVariable("httpbin") httpbin: String): Mono<String>
} (Repo with working example here: LINK) so, in this case: is it truly intended that the URL and other fields can be parameterized with application properties at all? If so, then this ticket shouldn't be closed as completed. Otherwise @jcthalys , I recommend taking the more verbose approach of providing a webClient with its baseUrl set per httpProxyFactory you need to build for the time being, and not setting the URL property at the annotation level. It's the approach I'll be taking for the time being. |
Uh oh!
There was an error while loading. Please reload this page.
Affects: 6.0.0-SNAPSHOT
Hi Spring Team,
Can you please add the ability to reference properties for
@HttpExchange
,@GetExchange
, and@PostExchange
defined inapplication.yaml
?Right now, I have to hard code my URL in the annotation:
But I wish to define my URL in
application.yaml
and reference it in the annotations like this:The text was updated successfully, but these errors were encountered: