在Feign Client Java中将空集传递到请求参数

问题描述

我的假装客户有问题。 我有看起来像这样的休息资源

    @GetMapping("/query")
    public Set<Long> getTenantIdsByPropertyId(@AuthenticationPrincipal UserPrincipal principal,@RequestParam @Positive Long propertyId,@RequestParam(required = false) Set<ContractStatus> statuses) {
    return contractService.getTenantIdsByPropertyId(principal.getorganizationId(),propertyId,statuses);
}

我想使用伪装客户端从另一个微服务中调用此终结点

    @GetMapping("/query")
    Set<Long> getTenantIdsByPropertyId(@RequestHeader("Cookie") String cookie,@RequestParam(name = "propertyId") Long propertyId,@RequestParam(name = "statuses") Collection<ContractStatus> statuses)
        throws RequestProcessingException;

ContractStatus只是一个常规枚举。

但是当我对此进行测试时,出现以下错误

2020-10-05 12:45:11.846 ERROR 27478 --- [nio-8083-exec-1] c.z.c.a.h.ApplicationExceptionHandler    : org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.util.Set'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam com.zpot.contract.common.enumeration.ContractStatus] for value 'null'; nested exception is java.lang.IllegalArgumentException: No enum constant com.zpot.contract.common.enumeration.ContractStatus.null

问题是如何使用伪客户端传递空集以调用端点? 预先感谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)