我在Micronaut2.2.1中使用Java15记录功能,序列化不起作用
{
"message": "Failed to convert argument [model] for value [null] due to: Cannot construct instance of `view.model.product.ProductViewModel` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)\n at [Source: UNKNOWN; line: -1, column: -1]",
"path": "/model",
"_links": {
"self": {
"href": "/api/v1/product",
"templated": false
}
}
}
productviewmodel记录
public record ProductViewModel
(
@Nullable
@JsonProperty("id")
String id,
@Nullable
@JsonProperty("name")
String name,
@Nullable
@JsonProperty("description")
String description,
@Nullable
@JsonProperty("price")
float price
) {
}
控制器
public Single<HttpResponse<?>> Create(@Body ProductViewModel model) {
LOG.info(String.format("Controller --> Creating new product"));
return iProductManager.Create(model).map(item -> HttpResponse.created(item));
}
1条答案
按热度按时间14ifxucb1#
我失踪了
@Introspected
记录中的注解