2017-08-31 4 views
1

Ich habe eine einfache SteuerungDe-Serialisierung Fehler Federverschluß reaktive

@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 
    } 
    ... 
} 

Auf diese URL aufrufen Ich erhalte die Ausnahme

"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] 

ich diesen Fehler zu verstehen und in der Regel, würde ich nur noch hinzufügen eine Anmerkung erforderlich, wenn

@JsonDeserialize(as = SomeConcreteClass.class)

Aber in diesem Fall, an welches Flux konkrete Beispiel soll ich binden? Hat auch nicht Spring boot einen Standard-Auto-Deserializer für Reaktortypen (Mono, Flux)?

Mein Pom (relevante Sachen):

<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> 

Antwort

2

Sie verwenden eigentlich gerade jetzt Spring MVC.

Entfernen Sie die spring-boot-starter-web und stellen Sie sicher, dass keine andere Abhängigkeit es transitiv bringt.