A WebMvc Interceptor IOC xxxFeignService error. e: @Component public class AInterceptor extends HandlerInterceptorAdapter { private InfoFeign infoFeign; }

@FeignClient(value = "test") public interface InfoFeign extends InfoServiceApi { }

Exception: Requested bean is currently in creation: Is there an unresolvable circular reference?

Comment From: spencergibb

You've not shown how you use the feign client in the other bean. Typically it means you're trying to use it in a constructor. Try injecting an ObjectProvider<FeignClient> to see if that helps. If not you'll have to initiate the work based on a Spring application event.

Comment From: huguangquan

You've not shown how you use the feign client in the other bean. Typically it means you're trying to use it in a constructor. Try injecting an ObjectProvider<FeignClient> to see if that helps. If not you'll have to initiate the work based on a Spring application event.

Service Consumer java files:

@Configuration public class WebConfiguration implements WebMvcConfigurer { @Autowired private AInterceptor aInterceptor ; @Bean public WebMvcConfigurer WebMvcConfigurer() { return new WebMvcConfigurer() { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(aInterceptor); } } }

@Component public class AInterceptor extends HandlerInterceptorAdapter { @Autowired private InfoFeign infoFeign; public void test() { // ...... infoFeign.doService(); // ...... } }

@FeignClient(value = "test") public interface InfoFeign extends InfoServiceApi { }

Service Provider Module Java file: public interface InfoServiceApi { @PostMapping("/doService") Result doService(); }

Comment From: spencergibb

Using the feign client in the interceptor is too early in the spring lifecycle. I'd recommend using web client or rest template.