一、遇到的问题

报错:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-11-14 21:05:41.366 ERROR 24464 --- [           main] o.s.boot.SpringApplication               : Application run failed

原因:
在项目的Service实现类中没有引入@Service对应的包 org.apache.dubbo.config.annotation.Service

二、解决方法

方法1:
引入@Service注解对应的包 org.apache.dubbo.config.annotation.Service

import org.apache.dubbo.config.annotation.Service;

@Service
public class LotteryActivityDeploy implements ILotteryActivityDeploy {
}

其他方法:

造成该报错无非这几个原因:扫描不到包、导包导错、注解没加或加错,类型、类名不正确等

排查:查看报错所有日志的Caused by,原因往往在最后一个Caused by。

附件

参考:Error creating bean with name的最佳解决方法

报错:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-11-14 21:05:41.366 ERROR 24464 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activityServiceImpl': Injection of @DubboReference dependencies is failed; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.nxg.lottery.rpc.activity.deploy.ILotteryActivityDeploy. No provider available for the service com.nxg.lottery.rpc.activity.deploy.ILotteryActivityDeploy from the url dubbo://192.168.56.1/com.nxg.lottery.rpc.activity.deploy.ILotteryActivityDeploy?application=lottery-erp&application.version=1.0.0&dubbo=2.0.2&init=false&interface=com.nxg.lottery.rpc.activity.deploy.ILotteryActivityDeploy&metadata-type=remote&methods=queryActivityListByPageForErp&pid=24464&qos.enable=false&register.ip=192.168.56.1&release=2.7.10&revision=0.0.1-SNAPSHOT&side=consumer&sticky=false&timestamp=1699967140428 to the consumer 192.168.56.1 use dubbo version 2.7.10
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:149) ~[spring-context-support-1.0.10.jar:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1430) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:755) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:402) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
	at com.nxg.lottery.erp.LotteryErpApplication.main(LotteryErpApplication.java:23) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.nxg.lottery.rpc.activity.deploy.ILotteryActivityDeploy. No provider available for the service com.nxg.lottery.rpc.activity.deploy.ILotteryActivityDeploy from the url dubbo://192.168.56.1/com.nxg.lottery.rpc.activity.deploy.ILotteryActivityDeploy?application=lottery-erp&application.version=1.0.0&dubbo=2.0.2&init=false&interface=com.nxg.lottery.rpc.activity.deploy.ILotteryActivityDeploy&metadata-type=remote&methods=queryActivityListByPageForErp&pid=24464&qos.enable=false&register.ip=192.168.56.1&release=2.7.10&revision=0.0.1-SNAPSHOT&side=consumer&sticky=false&timestamp=1699967140428 to the consumer 192.168.56.1 use dubbo version 2.7.10
	at org.apache.dubbo.config.ReferenceConfig.checkInvokerAvailable(ReferenceConfig.java:444) ~[dubbo-2.7.10.jar:2.7.10]
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:318) ~[dubbo-2.7.10.jar:2.7.10]
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:206) ~[dubbo-2.7.10.jar:2.7.10]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:163) ~[dubbo-2.7.10.jar:2.7.10]
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.getInjectedObject(AbstractAnnotationBeanPostProcessor.java:362) ~[spring-context-support-1.0.10.jar:na]
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor$AnnotatedFieldElement.inject(AbstractAnnotationBeanPostProcessor.java:542) ~[spring-context-support-1.0.10.jar:na]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:145) ~[spring-context-support-1.0.10.jar:na]
	... 18 common frames omitted
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐