请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

一个项目有多个feignClient报错

原项目有用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?




正在回答 回答被采纳积分+3

1回答

廖师兄 2020-04-01 01:22:24

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

0 回复 有任何疑惑可以回复我~
  • 提问者 寒暄丶 #1
    使用了@Lazy注解让其中一个client执行了懒加载,不知道这样治标不治本的方式可不可以用
    回复 有任何疑惑可以回复我~ 2020-04-01 09:06:17
  • 廖师兄 回复 提问者 寒暄丶 #2
    建议把逻辑多缕缕清楚,死循环肯定是逻辑不通。
    回复 有任何疑惑可以回复我~ 2020-04-07 00:46:16
  • 根本不是业务循环依赖问题=-=,应该是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 13:12:00
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号