Dubbo服务启动失败:<dubbo:service interface=““ /> interface not allow null!

最近升级框架版本:

spring boot:2.2.5 --> 2.3.2

spring cloud:Hoxton.SR3 --> Hoxton.SR8

spring cloud alibaba:2.2.1 --> 2.2.3

dubbo:2.7.6 --> 2.7.8

升级后某服务启动失败,异常日志:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxController' defined in file [xxxController.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ServiceBean:IXxxDubboService': Cannot resolve reference to bean 'bDubboServiceProvider' while setting bean property 'ref'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bDubboServiceProvider': Unsatisfied dependency expressed through field 'xxxService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aServiceImpl' defined in file [aServiceImpl.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ServiceBean:IzzzDubboService': Cannot resolve reference to bean 'cDubboServiceProvider' while setting bean property 'ref'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cDubboServiceProvider': Injection of @DubboReference dependencies is failed; nested exception is java.lang.IllegalStateException:  interface not allow null!
......
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bDubboServiceProvider': Injection of @DubboReference dependencies is failed; nested exception is java.lang.IllegalStateException:  interface not allow null!
......

问题原因:经排查发现是某位开发同事写的a服务和b服务(dubbo)互相引用导致,但是在原版本中没有此异常发生。

解决方案:与spring的循环依赖类似,最简单的方案是在引用的服务实例上加@Lazy注解,最合理的方案是做代码拆分,写服务代码时还是要多加注意。

你可能感兴趣的:(spring,cloud,alibaba,dubbo,微服务,java)