问题:
ERROR:Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.netflix.hystrix.exception.HystrixRuntimeException: SkuFeign#search(Map) failed and no fallback available.] with root cause
com.netflix.client.ClientException: Load balancer does not have available server for client: xxxxx
**
出现该错误的原因为Feign调用中未能找到调取的方法
**
原因一:
启动类中没有以正确的路径找到Feign @EnableFeignClients
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients(basePackages = "com.xm.search.feign")
public class SearchWebApplication{
public static void main(String[] args) {
SpringApplication.run(SearchWebApplication.class,args);
}
}
原因二:
①用于被调用的Feign类未被纳入Spring容器中 @Component
②指定微服务名称错误 @FeignClient
@Component
@FeignClient(name = "search")
@RequestMapping(value = "/search")
原因三:
Feign的微服务模块启动时还没完全启动完成就让其他模块微服务启动
原因四:
查看其它微服务模块,是否出现被feign调用的方法出现错误,如:未开虚拟机,导致前面ServiceImpl等方法无法获取数据库信息等。
更多原因(收纳其他帖子)
1.controller层没有加@ResponseBody
2.Service层实现类未添加注解@Autowired