[英]Spring webflux with webclient bodyToMono UnsupportedMediaTypeException Content type 'application/json' not supported
I have spring application with web client making calls to other REST end-points.我有 spring 应用程序和 web 客户端调用其他 REST 端点。 Below is the client -下面是客户端——
@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);
}
During testing, I get this error exactly at bodyToMono在测试期间,我在 bodyToMono 得到了这个错误
Suppressed: org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'application/json' not supported for bodyType=io.atlassian.identity.directorymerge.perms.model.SearchPrincipalsByResourceResponse
I'm using immutable and below is the SearchPrincipalsByResourceResponse class我使用的是不可变的,下面是 SearchPrincipalsByResourceResponse class
@Value.Immutable
@JsonAutoDetect
@JsonSerialize(as = ImmutableSearchPrincipalsByResourceResponse.class)
@JsonDeserialize(as = ImmutableSearchPrincipalsByResourceResponse.class)
public abstract class SearchPrincipalsByResourceResponse {
public abstract List<SearchResult> getResults();
}
Any help is much appreciated.任何帮助深表感谢。 I have been stuck here for a while now.我已经被困在这里一段时间了。
Finally, I was able to solve the problem by setting the attribute最后,我能够通过设置属性来解决问题
@Value.Style(jdkOnly = true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.