通过RestTemplate交换发送对象,没有FilterProvider配置的问题

时间:2019-07-12 13:38:19

标签: java patch spring-restcontroller

我调用微服务进行修补,如下所示:

CustomerPatch customerPatch = new CustomerPatch();
customerPatch.setStatus(CLAIMED_OWNER_STATUS);
HttpEntity<MappingJacksonValue> httpEntityPatchCustomer = new HttpEntity(customerPatch, headers);

ResponseEntity<Object> patchPartyResponse = restTemplate
      .exchange(utilityProvider.getPatchCustomerURI(individual.getId()), HttpMethod.PATCH, httpEntityPatchCustomer,
          Object.class);

被调用的rest方法的签名如下:

public MappingJacksonValue patchCustomer(@RequestHeader HttpHeaders headers,
  @PathVariable(value = "id") String customerPartyRoleId,
  @RequestBody CustomerPatch customerPatch)

CustomerPatch如下:

@Data
@ApiModel
@JsonFilter("se.telenor.customer.management.model.CustomerPatch")
public class CustomerPatch {
  @JsonIgnore
  public static final String JSON_FILTER_ID = "se.telenor.customer.management.model.CustomerPatch";

  @ApiModelProperty(required = true, position = 1, example = "INITIALIZED|CLAIMED",
      dataType = "java.lang.String")
  @JsonProperty("status")
  private String status;
}

我收到以下异常:

org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class se.telenor.customer.management.model.CustomerPatch]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot resolve PropertyFilter with id 'se.telenor.customer.management.model.CustomerPatch'; no FilterProvider configured
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:293)
at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:103)
at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:938)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:732)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:709)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:597)

有人可以帮助我吗?

0 个答案:

没有答案