I have the following route in my application
@Bean
public RouterFunction<ServerResponse> route(UserHandler handler) {
return RouterFunctions.route(RequestPredicates.POST("/users"), handler::signup);
}
which is handled by the following method
public Mono<ServerResponse> signup(ServerRequest request) {
return request
.bodyToMono(User.class)
.map(user -> {
user.setPassword(encoder.encode(user.getPassword()));
return user;
})
.flatMap(repository::save)
.map(user -> tokenService.create(user.getId()))
.map(TokenDto::new)
.flatMap(tokenDto -> ServerResponse.ok().body(tokenDto, TokenDto.class));
}
When I issue a valid request to the endpoint, the following error is logged
'producer' type is unknown to ReactiveAdapterRegistry
Having investigated the issue with a debugger, I see that my handler's signup method completes successfully, so I'm assuming the router doesn’t like the return value, but I'm not sure why?
I have the same problem with you, the same error.
Finally I change the code using bodyValue method not body(T,Class),you can try this: ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).bodyValue(tokenDto)
。