我有一个带有web客户端的spring应用程序,它可以调用其他REST端点。以下是客户-
@Override
public Mono<SearchPrincipalsByResourceResponse> searchPrincipalsByResource(SearchPrincipalsByResourceRequest searchPrincipalsByResourceRequest) {
return webClient
.post()
.uri(uriBuilder -> uriBuilder.path(BASE_PATH + SEARCH_PRINCIPALS_BY_RESOURCE_PATH).build())
.accept(APPLICATION_JSON)
.body(Mono.just(searchPrincipalsByResourceRequest), SearchPrincipalsByResourceRequest.class)
.retrieve()
.bodyToMono(SearchPrincipalsByResourceResponse.class);
}
在测试过程中,我在bodyToMono 上得到了这个错误
Suppressed: org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'application/json' not supported for bodyType=io.atlassian.identity.directorymerge.perms.model.SearchPrincipalsByResourceResponse
我使用的是不可变的,下面是SearchPrincipalsByResourceResponse类
@Value.Immutable
@JsonAutoDetect
@JsonSerialize(as = ImmutableSearchPrincipalsByResourceResponse.class)
@JsonDeserialize(as = ImmutableSearchPrincipalsByResourceResponse.class)
public abstract class SearchPrincipalsByResourceResponse {
public abstract List<SearchResult> getResults();
}
非常感谢您的帮助。我被困在这里有一段时间了。
最后,我通过设置属性解决了这个问题
@Value.Style(jdkOnly = true)