roy*_*oyB 4 spring reactor jackson spring-boot spring-webflux
我有一个简单的控制器
@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
}
...
}
Run Code Online (Sandbox Code Playgroud)
在调用此网址时,我收到异常
"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]
Run Code Online (Sandbox Code Playgroud)
我理解这个错误,通常,如果需要,我只会添加一个注释
@JsonDeserialize(as = SomeConcreteClass.class)
但是在这种情况下,我应该绑定到哪个 Flux 具体示例?此外,是否没有Spring boot用于 Reactor 类型(单声道、通量)的默认自动解串器?
我的pom(相关的东西):
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3114 次 |
| 最近记录: |