• Spring 6.0.0-M4
  • Java 17
  • Example Codes to reproduce: https://github.com/hantsy/spring6-sandbox/tree/master/declarative-http-client

The client example is like this.

@HttpExchange(url = "/posts", accept = "application/json", contentType = "application/json")
public interface PostClient {
    @GetExchange("")
    Flux<Post> allPosts();

    @GetExchange("/{id}")
    Mono<Post> getById(@PathVariable("id") UUID id);

    @PostExchange("")
    Mono<ResponseEntity<Void>> save(@RequestBody Post post);

    @PutExchange("/{id}")
    Mono<ResponseEntity<Void>> update(@PathVariable UUID id, @RequestBody Post post);

    //@DeleteExchange("/{id}")
    Mono<ResponseEntity<Void>> delete(@PathVariable UUID id);

}

When I tried to run my tests, got the exceptions like this.

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.demo.PostClient]: Factory method 'postClient' threw exception; nested exception is o
rg.springframework.core.annotation.AnnotationConfigurationException: Misconfigured aliases: attribute 'url' in annotation [org.springframework.web.service.annotation.PutExchange] and a
ttribute 'url' in annotation [org.springframework.web.service.annotation.HttpExchange] must declare the same return type.

In the HttpExchange, the url is a String.

public @interface HttpExchange {

    /**
     * This is an alias for {@link #url}.
     */
    @AliasFor("url")
    String value() default "";

    /**
     * The URL for the request, either a full URL or a path only that is relative
     * to a URL declared in a type-level {@code @HttpExchange}, and/or a globally
     * configured base URL.
     * <p>By default, this is empty.
     */
    @AliasFor("value")
    String url() default "";

But in the PutExchange, it becomes String[].

public @interface PutExchange {

    /**
     * Alias for {@link HttpExchange#value}.
     */
    @AliasFor(annotation = HttpExchange.class)
    String[] value() default {};

    /**
     * Alias for {@link HttpExchange#url()}.
     */
    @AliasFor(annotation = HttpExchange.class)
    String[] url() default {};

Comment From: bclozel

Duplicates #28498