javascript
Spring Cloud异常
Feign
獲取不到bean
一直獲取不到bean,注解都加了,仍然獲取不到。在@EnableCloudFeignClients上添加basePackages = {"com.jurassic.cloud","com.jurassic.object.api.feign"}強(qiáng)制掃描,提示
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.jurassic.object.api.feign.BoApiService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: PathVariable annotation was empty on param 0.
解決方法:
使用Feign的時(shí)候,如果參數(shù)中帶有@PathVariable形式的參數(shù),則要用value=""標(biāo)明對(duì)應(yīng)的參數(shù),否則會(huì)拋出IllegalStateException異常
@PutMapping("/disuseable/{sn}")
ApiResponse disUseAble(@PathVariable String sn); ? // wrong
//改成
@PutMapping("/disuseable/{sn}")
ApiResponse disUseAble(@PathVariable(value="sn") String sn); ?// right
總結(jié)
以上是生活随笔為你收集整理的Spring Cloud异常的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。