Springboot項目整合了Feign,一直都啟動好好的,加了幾個接口后准備測試時就啟動不了了,一直報以下錯誤:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.ks.feign.xxxFeign': FactoryBean threw exception on object creation; nested exception is java.lang.UnsupportedOperationException
檢查了好幾遍終於找到問題了
原來是聲明接口參數的注釋的時候偷懶,直接復制而忘了改@RequestParam的value,導致兩個參數注解的value都是一樣的,就被檢測出來了。
在@FeignClient()接口類中,使用@RequestParam時必須指定value,Spring 在這方面有很好的封裝特性並嚴格校驗。