Blaze 持久化 UpdatableEntityView 作为 spring 启动请求正文
Blaze persistence UpdatableEntityView as spring boot request body
我正在尝试使用 blaze persistence UpdatableEntityView 作为带有 spring 引导的请求主体。
以下是 UpdatableEntityView
的代码
@UpdatableEntityView
@EntityView(DealListing.class)
public interface DealListingUpdateView {
@IdMapping
Long getId();
void setId(Long id);
Instant getListedOn();
void setListedOn(Instant listedOn);
}
以下是其余的控制器映射
@PutMapping("/deal-listings/sell/{id}")
public void test(@PathVariable Long id, @RequestBody DealListingUpdateView dealListingUpdateView){
dealListingService.testUpdate(id, dealListingUpdateView);
}
以下是 pom.xml 执行 blaze 持久性文档中指定的反序列化的依赖项
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jackson</artifactId>
<scope>compile</scope>
</dependency>
但是当我提交请求时出现以下错误
Type definition error: [simple type, class com.ilex.tradeservice.domain.view.blaze.DealListingUpdateView]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.ilex.tradeservice.domain.view.blaze.DealListingUpdateView` (no Creators, like default constructor, 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]
如您在文档中所见,您将需要 Spring Data WebMvc 集成:https://persistence.blazebit.com/documentation/1.6/entity-view/manual/en_US/index.html#spring-data-webmvc-integration
您还必须使用 @EntityViewId("id")
额外注释您的控制器参数
@PutMapping("/deal-listings/sell/{id}")
public void test(@PathVariable Long id, @EntityViewId("id") @RequestBody DealListingUpdateView dealListingUpdateView){
dealListingService.testUpdate(id, dealListingUpdateView);
}
我正在尝试使用 blaze persistence UpdatableEntityView 作为带有 spring 引导的请求主体。 以下是 UpdatableEntityView
的代码@UpdatableEntityView
@EntityView(DealListing.class)
public interface DealListingUpdateView {
@IdMapping
Long getId();
void setId(Long id);
Instant getListedOn();
void setListedOn(Instant listedOn);
}
以下是其余的控制器映射
@PutMapping("/deal-listings/sell/{id}")
public void test(@PathVariable Long id, @RequestBody DealListingUpdateView dealListingUpdateView){
dealListingService.testUpdate(id, dealListingUpdateView);
}
以下是 pom.xml 执行 blaze 持久性文档中指定的反序列化的依赖项
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jackson</artifactId>
<scope>compile</scope>
</dependency>
但是当我提交请求时出现以下错误
Type definition error: [simple type, class com.ilex.tradeservice.domain.view.blaze.DealListingUpdateView]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.ilex.tradeservice.domain.view.blaze.DealListingUpdateView` (no Creators, like default constructor, 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]
如您在文档中所见,您将需要 Spring Data WebMvc 集成:https://persistence.blazebit.com/documentation/1.6/entity-view/manual/en_US/index.html#spring-data-webmvc-integration
您还必须使用 @EntityViewId("id")
@PutMapping("/deal-listings/sell/{id}")
public void test(@PathVariable Long id, @EntityViewId("id") @RequestBody DealListingUpdateView dealListingUpdateView){
dealListingService.testUpdate(id, dealListingUpdateView);
}