org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productController': Unsatisfied dependency expressed through field 'iProductClientService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cn.wxm.service.IProductClientService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No fallbackFactory instance of type class cn.wxm.config.IProductClientServiceFallbackFactory found for feign client WXMCLOUD-PROVIDER-PRODUCT
本来以为回调函数不用加注入spring容器,结果报错了
加上@Configuration注解即可
@Configuration
public class IProductClientServiceFallbackFactory implements FallbackFactory<IProductClientService> {
@Override
public IProductClientService create(Throwable throwable) {
return new IProductClientService() {
@Override
public Product getProduct(String id) {
Product p = new Product();
p.setName("feign-hystrix");
p.setDec("feign-hystrix");
return p;
}
};
}
}