低版本idea使用@FeignClient导致 RequestParam.value() was empty
程序员文章站
2022-07-14 10:30:09
...
低版本idea使用@FeignClient导致 RequestParam.value() was empty
1.问题发现
在开发过程中发现了一个令人脑壳疼的问题,就是在使用@FeignClient时,idea总是报错,但是别的同事运行代码却没有问题,
唯一的区别就是本人使用的idea版本较低,为2018年的版本。
错误如下:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.x.x.xxFeignClient': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: RequestParam.value() was empty on parameter 0
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:178)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1674)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1249)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:257)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1474)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1431)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1214)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
... 45 common frames omitted
Caused by: java.lang.IllegalStateException: RequestParam.value() was empty on parameter 0
at feign.Util.checkState(Util.java:130)
2.问题解决
为了解决这个问题,查了一波资料。终于!!!
这个问题有两种解决方案:
方案一:简单粗暴, 升级idea至2019以上版本
方案二:加上 -parameters参数,如图1,然后重新编译项目,如图2,就可以运行成功了
以上是自己学习过程的理解,如有不妥,谢谢指正~
点个赞再走哦,哈哈哈