Question 3

describe

When the service consumer project is not started, an error is reported:

2021-03-23 17:51:28.610 ERROR 15728 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testConsumerProviderServiceController': Unsatisfied dependency expressed through field 'remoteProviderService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteProviderServiceImpl': Injection of @DubboReference dependencies is failed; nested exception is java.lang.IllegalStateException: Failed to check the status of the service org.example.common.service.ProviderService. No provider available for the service org.example.common.service.ProviderService from the url registry://localhost:9090/org.apache.dubbo.registry.RegistryService? Application=consumer&dubbo=2.0.2&init=false&interface=org.example.com mon. Service. ProviderService&metadata -type = remote&me Thods = test&pid = 15728 & qos. Accept. Foreign. IP = false&qos. Enable = false&register. IP = 192.168.0.168 & registry = spring - cloud&releas E =2.7.8&side=consumer&sticky=false&timeout=10000&timestamp=1616493088059 to the consumer 192.168.0.168 use dubbo version 2.7.8at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(Autowired AnnotationBeanPostProcessor.java:643) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotat ionBeanPostProcessor.java:399) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFac tory.java:1420) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFac tory.java:593) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFacto ry.java:516) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory .java:897) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContex t.java:879) ~[spring-context-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationConte xt.java:143) ~[spring-boot-2.32..RELEASE.jar:2.32..RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.32..RELEASE.jar:2.32..RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.32..RELEASE.jar:2.32..RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.32..RELEASE.jar:2.32..RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.32..RELEASE.jar:2.32..RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.32..RELEASE.jar:2.32..RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.32..RELEASE.jar:2.32..RELEASE]
	at com.example.consumer.ConsumerBootstrap.main(ConsumerBootstrap.java:14) [main/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteProviderServiceImpl': Injection of @DubboReference dependencies is failed; nested exception is java.lang.IllegalStateException: Failed to check the status of the service org.example.common.service.ProviderService. No provider available for the service org.example.common.service.ProviderService from the url registry://localhost:9090/org.apache.dubbo.registry.RegistryService? Application=consumer&dubbo=2.0.2&init=false&interface=org.example.com mon. Service. ProviderService&metadata -type = remote&me Thods = test&pid = 15728 & qos. Accept. Foreign. IP = false&qos. Enable = false&register. IP = 192.168.0.168 & registry = spring - cloud&releas E =2.7.8&side=consumer&sticky=false&timeout=10000&timestamp=1616493088059 to the consumer 192.168.0.168 use dubbo version 2.7.8at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnota tionBeanPostProcessor.java:149) ~[spring-context-support-1.010..jar:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFac tory.java:1425) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFac tory.java:593) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFacto ry.java:516) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java :1307) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(Autowired AnnotationBeanPostProcessor.java:640) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE]
	... 20 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to check the status of the service org.example.common.service.ProviderService. No provider available for the service org.example.common.service.ProviderService from the url registry://localhost:9090/org.apache.dubbo.registry.RegistryService? Application=consumer&dubbo=2.0.2&init=false&interface=org.example.com mon. Service. ProviderService&metadata -type = remote&me Thods = test&pid = 15728 & qos. Accept. Foreign. IP = false&qos. Enable = false&register. IP = 192.168.0.168 & registry = spring - cloud&releas E =2.7.8&side=consumer&sticky=false&timeout=10000&timestamp=1616493088059 to the consumer 192.168.0.168 use dubbo version 2.7.8
	at org.apache.dubbo.config.ReferenceConfig.checkInvokerAvailable(ReferenceConfig.java:420) ~[dubbo-2.78..jar:2.78.]
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:315) ~[dubbo-2.78..jar:2.78.]
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:205) ~[dubbo-2.78..jar:2.78.] at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(Reference AnnotationBeanPostProcessor.java:144) ~[dubbo-2.78..jar:2.78.] at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.getInjectedObject(AbstractAnnotationBean PostProcessor.java:362) ~[spring-context-support-1.010..jar:na] at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor$AnnotatedFieldElement.inject(AbstractAnn otationBeanPostProcessor.java:542) ~[spring-context-support-1.010..jar:na]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) ~[spring-beans-5.28..RELEASE.jar:5.28..RELEASE] at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnota tionBeanPostProcessor.java:145) ~[spring-context-support-1.010..jar:na]
	... 31 common frames omitted

2021-03-23 17:51:28.612  INFO 15728 --- [Report-thread-1] c.a.n.client.config.NacosConfigService   : [fixed-127.0. 01 _8848.] [publish-single] ok, dataId=org.example.common.service.ProviderService:::consumer:consumer, group=dubbo, tenant=, config={"init":"false"."side":"consumer"."metadata-type":"remote"."application":"consumer"."release":"2.7.8...

Copy the code

why

For the service consumer, the required service is not started and the consumer’s start is stuck in checking and retrying the service.

The solution

Methods a

Add the following parameters to the @dubboReference annotation:

@Service
public class RemoteProviderServiceImpl implements RemoteProviderService {
    public static final Logger logger = LoggerFactory.getLogger(RemoteProviderServiceImpl.class);
    @DubboReference(retries = 0,check = false)
    private ProviderService providerService;

    @Override
    public String testRemoteProviderService(a) {
        logger.info("Consumers start spending =======");
        returnproviderService.test(); }}Copy the code
Method 2 (Recommended)

Specify the dubo.consumer.check configuration in the project configuration file

dubbo.consumer.check=false
Copy the code