I have a simple controller
@RestController
@RequestMapping("path")
public class MyController {
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public Flux<SomeObject> run(@RequestBody Flux<RequestObject> request){
//do something and return flux
}
...
}
On calling this url I'm getting the exception
"Type definition error: [simple type, class reactor.core.publisher.Flux]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Can not construct instance of reactor.core.publisher.Flux (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information\n at [Source: (PushbackInputStream); line: 1, column: 1]
I understand this error and usually, I would just add an annotation if needed
@JsonDeserialize(as = SomeConcreteClass.class)
But in this case, to which Flux concrete example should I bind? Also, Doesn't Spring boot
has a default auto-deserializers for Reactor Types (Mono, Flux)?
My pom (relevant stuff):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
You're actually using Spring MVC right now.
Remove the spring-boot-starter-web
and make sure no other dependency brings it transitively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With