1.報ClassNotFound com.netflix.config.CachedDynamicIntProperty問題,原因是spring-cloud-starter-openfeign的spring-cloud-starter-netflix-archaius中沒有CachedDynamicIntProperty這個類。 引入archaius-core的核心包即可,注意報錯這里的com.google.common.collect.FluentIterable.append(Ljava/lang/Iterable;)Lcom/google/common/collect/FluentIterable; but it does not exist 所以需要排除guava
<dependency>
<groupId>com.netflix.archaius</groupId>
<artifactId>archaius-core</artifactId>
<version>0.7.6</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
2.feign.FeignException: status 405 reading FeignClient#getXXX(Long),405錯誤為請求方式不一致,明明定義的是GET請求,結果在發起service to service call時,被轉換成了POST請求。原因是OpenFeign在構造請求時需要足夠多的@RequestMapping/@RequestParam/@PathVariable/@RequestHeader等來構造http請求。通過閱讀自己定義的FeignClient可以發現,GET請求中的參數定義缺少注解@RequestParam,故而報錯。所以當使用feign傳參數的時候,需要加上@RequestParam注解,否則對方服務無法識別參數。
