一个项目有多个feignClient报错

来源:5-5 Feign的使用

寒暄丶

2020-03-31

原项目有用feign在拦截器上调用会员中心服务来校验用户权限,最近这个项目需要调用另外一个商城相关的服务,所以又写了个feignclient,但是报错,看报错感觉像是循环注入了(报错信息摘要如下),我看了下好像是【orderController -> payOrderFacade(聚合类) -> pmsTermGoodsService(当前项目实现类) -> sscClient(商城中心) -> webConfigure -> authInterceptor(拦截器) -> memberClient(拦截器autowire的member的feign客户端) 】但是不太清楚为什么会这样,这种情况是循环注入还是说一个项目里不能定义有多个feign客户端来调用其他服务呢,求老师解答

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderController': Unsatisfied dependency expressed through field 'payOrderFacade'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'payOrderFacade': Unsatisfied dependency expressed through field 'pmsTermGoodsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pmsTermGoodsServiceImpl': Unsatisfied dependency expressed through field 'sscClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pms.feign.client.SscClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webConfigure': Unsatisfied dependency expressed through field 'authInterceptor'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authInterceptor': Unsatisfied dependency expressed through field 'memberClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pay.client.MemberClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation: Is there an unresolvable circular reference?
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)
	at com.mbkj.mall.MallServiceApplication.main(MallServiceApplication.java:37)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'payOrderFacade': Unsatisfied dependency expressed through field 'pmsTermGoodsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pmsTermGoodsServiceImpl': Unsatisfied dependency expressed through field 'sscClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pms.feign.client.SscClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webConfigure': Unsatisfied dependency expressed through field 'authInterceptor'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authInterceptor': Unsatisfied dependency expressed through field 'memberClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pay.client.MemberClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation: Is there an unresolvable circular reference?

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pmsTermGoodsServiceImpl': Unsatisfied dependency expressed through field 'sscClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pms.feign.client.SscClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webConfigure': Unsatisfied dependency expressed through field 'authInterceptor'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authInterceptor': Unsatisfied dependency expressed through field 'memberClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pay.client.MemberClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation: Is there an unresolvable circular reference?

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pms.feign.client.SscClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webConfigure': Unsatisfied dependency expressed through field 'authInterceptor'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authInterceptor': Unsatisfied dependency expressed through field 'memberClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pay.client.MemberClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation: Is there an unresolvable circular reference?

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webConfigure': Unsatisfied dependency expressed through field 'authInterceptor'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authInterceptor': Unsatisfied dependency expressed through field 'memberClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pay.client.MemberClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation: Is there an unresolvable circular reference?

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webConfigure': Unsatisfied dependency expressed through field 'authInterceptor'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authInterceptor': Unsatisfied dependency expressed through field 'memberClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pay.client.MemberClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation: Is there an unresolvable circular reference?
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586)

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authInterceptor': Unsatisfied dependency expressed through field 'memberClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pay.client.MemberClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation: Is there an unresolvable circular reference?

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mbkj.mall.pay.client.MemberClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation: Is there an unresolvable circular reference?

Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation: Is there an unresolvable circular reference?




写回答

1回答

廖师兄

2020-04-01

看着像是循环调用,一旦用了拦截器,一不小心就出现循环调用,查问题从拦截器里着手。

0
3
慕移动55892898
回复
廖师兄
根本不是业务循环依赖问题=-=,应该是feignclient使得spring组件mvcResourceUrlProvider出现循环依赖了 我也是拦截器使用了feignClient,就报错: userLoginerAuthTransactionalService(业务bean1) loginerClientService(业务bean2) loginerUpdateService(业务bean3) loginerUpdateFeignService(业务feignclient) org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration authInterceptor(登录拦截器) loginClientService(业务bean4) loginerQueryService(业务bean5) loginerQueryFeignService(业务feignclient2) Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation: Is there an unresolvable circular reference?
2020-07-01
共3条回复

SpringCloud Finchley(M2+RELEASE+SR2)微服务实战

SpringCloud组件实现微服务,【已升级Finchley.Release】

5668 学习 · 2489 问题

查看课程