前几天同事使用feign调API的时候报错:
java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableCollection.add(Collections.java:1055) at org.springframework.cloud.openfeign.support.FeignUtils.addTemplateParameter(FeignUtils.java:60) at org.springframework.cloud.openfeign.support.SpringMvcContract$SimpleAnnotatedParameterContext.setTemplateParameter(SpringMvcContract.java:460) at org.springframework.cloud.openfeign.annotation.RequestParamParameterProcessor.processArgument(RequestParamParameterProcessor.java:69) at org.springframework.cloud.openfeign.support.SpringMvcContract.processAnnotationsOnParameter(SpringMvcContract.java:292) at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:110) at org.springframework.cloud.openfeign.support.SpringMvcContract.parseAndValidateMetadata(SpringMvcContract.java:188) at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:66) at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:154) at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:52) at feign.Feign$Builder.target(Feign.java:251) at feign.Feign$Builder.target(Feign.java:247) at com.supermap.sinfcloud.common.feign.FeignService.newWebApiByName(FeignService.java:81) at com.supermap.sinfcloud.common.feign.FeignService.newWebApiByName(FeignService.java:71)
原因就是在处理feign API参数时候,参数名称出现多个重复的,就会导致feign处理参数出错!
@GetMapping("/test")
Message<?> apply(@RequestParam("userName") String userName,@RequestParam("userName") String userId);
还是少拷贝,仔细点好~