UnsupportedOperationException

在使用Springcloud搭建服务时,然后远程服务调用FeignClient(继承API Service服务发现,有实现接口,注解了@RestController)接口,

api工程包

@RequestMapping
public interface TestService{
   String test(@RequestParam("userId") Integer userId,
               RequestParam("userId") Integer atestparam,
               RequestParam("userId") Integer btestparam);
}

impl工程包

@RestController
public class TestServiceImpl implements TestService{
    @Override
    public String test(Integer userId,Integer atestparam,Integer btestparam){
        return "success";
    }
}

web工程包

启动类注解使用feign进行rpc调用 @EnableFeignClients

 在service层

@FeignClient("test-impl")//实现包 在注册中心的名称
public class TestServiceFeign extends TestService{//需要引用API工程包
    //此时已继承过来方法
}

此时我犯了一个极大的错误,由于工程是改造,很多方法我是Ctrl+C Ctrl+V 过来的

出现了下面这个错误

Caused by: java.lang.UnsupportedOperationException: null
	at java.util.Collections$UnmodifiableCollection.add(Collections.java:1055) ~[na:1.8.0_201]
	at org.springframework.cloud.openfeign.support.FeignUtils.addTemplateParameter(FeignUtils.java:60) ~[spring-cloud-openfeign-core-2.1.1.RELEASE.jar:2.1.1.RELEASE]
	at org.springframework.cloud.openfeign.support.SpringMvcContract$SimpleAnnotatedParameterContext.setTemplateParameter(SpringMvcContract.java:460) ~[spring-cloud-openfeign-core-2.1.1.RELEASE.jar:2.1.1.RELEASE]
	at org.springframework.cloud.openfeign.annotation.RequestParamParameterProcessor.processArgument(RequestParamParameterProcessor.java:69) ~[spring-cloud-openfeign-core-2.1.1.RELEASE.jar:2.1.1.RELEASE]
	at org.springframework.cloud.openfeign.support.SpringMvcContract.processAnnotationsOnParameter(SpringMvcContract.java:292) ~[spring-cloud-openfeign-core-2.1.1.RELEASE.jar:2.1.1.RELEASE]
	at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:110) ~[feign-core-10.1.0.jar:na]
	at org.springframework.cloud.openfeign.support.SpringMvcContract.parseAndValidateMetadata(SpringMvcContract.java:188) ~[spring-cloud-openfeign-core-2.1.1.RELEASE.jar:2.1.1.RELEASE]
	at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:66) ~[feign-core-10.1.0.jar:na]
	at feign.hystrix.HystrixDelegatingContract.parseAndValidatateMetadata(HystrixDelegatingContract.java:46) ~[feign-hystrix-10.1.0.jar:na]
	at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:154) ~[feign-core-10.1.0.jar:na]
	at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:52) ~[feign-core-10.1.0.jar:na]
	at feign.Feign$Builder.target(Feign.java:251) ~[feign-core-10.1.0.jar:na]
	at org.springframework.cloud.openfeign.HystrixTargeter.target(HystrixTargeter.java:55) ~[spring-cloud-openfeign-core-2.1.1.RELEASE.jar:2.1.1.RELEASE]
	at org.springframework.cloud.openfeign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:238) ~[spring-cloud-openfeign-core-2.1.1.RELEASE.jar:2.1.1.RELEASE]
	at org.springframework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:267) ~[spring-cloud-openfeign-core-2.1.1.RELEASE.jar:2.1.1.RELEASE]
	at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:247) ~[spring-cloud-openfeign-core-2.1.1.RELEASE.jar:2.1.1.RELEASE]
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	... 30 common frames omitted

浪费了我大半天时间来解决这个问题,写这个博客来记住警戒自己,做事情要仔细

相信在座的各位已经看出是什么原因导致这个错误了,

没错,就是API   TestService 这个类中,里面参数@RequestParam("userId") 出现了三次

我已经崩溃的彻底彻底的了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值