RemoteFallbackFactory扫包:No fallbackFactory instance of type class - xiaohouye

时间:2024-02-24 11:34:31

RemoteFallbackFactory扫包:No fallbackFactory instance of type class

 

调用feign接口出现 : FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No fallbackFactory instance of type class com*********RemoteFallbackFactory found for feign client appid

 

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'com*********Remote\': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No fallbackFactory instance of type class com*********RemoteFallbackFactory found for feign client appid
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:178)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1645)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1184)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:257)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1325)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1291)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1101)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584)

... 32 common frames omitted

 

原因:

需要在FallBackFActory中添加 

@Component注解

 

@Component
@Slf4j
public class AAARemoteFallbackFactory implements FallbackFactory<AAARemote> {
@Override
public AAARemote create(Throwable cause) {
return new AAARemote() {
@Override
public BizResponse<AAAResponse> getFunction(@RequestBody AAARequest request) {
log.error("AAARemoteFallbackFactory getAAARemote params:{} error:{}", JSON.toJSONString(request),JSON.toJSONString(cause.getMessage()));
                return new Response(ERROR.CODE);
}

};
}
}


 

AAA