About the problem that the service class cannot be found when springboot integrates dubbo

When doing the spring integration dubbo project, write the service interface and entity class into a common Maven project, inherit the service interface in the service provider, and call the service of the zookeeper registration center in the consumer. No error was reported when zookeeper and provider were started in sequence, but an error was reported when starting the consumer:

2022-03-10 21:09:20.286  INFO 18292 --- [           main] com.longtong.Application                 : Starting Application using Java 1.8.0_60 on LONGTONG with PID 18292 (E:\Java\IntelliJ IDEA 2019.3.3\longtong_SpringBoot\024_consumer\target\classes started by SAMSUNG in E:\Java\IntelliJ IDEA 2019.3.3\longtong_SpringBoot)
2022-03-10 21:09:20.288  INFO 18292 --- [           main] com.longtong.Application                 : No active profile set, falling back to 1 default profile: "default"
2022-03-10 21:09:20.683  INFO 18292 --- [           main] com.alibaba.spring.util.BeanRegistrar    : The Infrastructure bean definition [Root bean: class [org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nullwith name [referenceAnnotationBeanPostProcessor] has been registered.
2022-03-10 21:09:20.684  INFO 18292 --- [           main] com.alibaba.spring.util.BeanRegistrar    : The Infrastructure bean definition [Root bean: class [org.apache.dubbo.config.spring.beans.factory.annotation.DubboConfigAliasPostProcessor]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nullwith name [dubboConfigAliasPostProcessor] has been registered.
2022-03-10 21:09:20.685  INFO 18292 --- [           main] com.alibaba.spring.util.BeanRegistrar    : The Infrastructure bean definition [Root bean: class [org.apache.dubbo.config.spring.context.DubboLifecycleComponentApplicationListener]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nullwith name [dubboLifecycleComponentApplicationListener] has been registered.
2022-03-10 21:09:20.685  INFO 18292 --- [           main] com.alibaba.spring.util.BeanRegistrar    : The Infrastructure bean definition [Root bean: class [org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nullwith name [dubboBootstrapApplicationListener] has been registered.
2022-03-10 21:09:20.686  INFO 18292 --- [           main] com.alibaba.spring.util.BeanRegistrar    : The Infrastructure bean definition [Root bean: class [org.apache.dubbo.config.spring.beans.factory.config.DubboConfigDefaultPropertyValueBeanPostProcessor]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nullwith name [dubboConfigDefaultPropertyValueBeanPostProcessor] has been registered.
2022-03-10 21:09:20.895  INFO 18292 --- [           main] .b.f.a.ConfigurationBeanBindingRegistrar : The configuration bean definition [name : org.apache.dubbo.config.ApplicationConfig#0, content : Root bean: class [org.apache.dubbo.config.ApplicationConfig]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] has been registered.
2022-03-10 21:09:20.895  INFO 18292 --- [           main] com.alibaba.spring.util.BeanRegistrar    : The Infrastructure bean definition [Root bean: class [com.alibaba.spring.beans.factory.annotation.ConfigurationBeanBindingPostProcessor]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nullwith name [configurationBeanBindingPostProcessor] has been registered.
2022-03-10 21:09:20.895  INFO 18292 --- [           main] .b.f.a.ConfigurationBeanBindingRegistrar : The configuration bean definition [name : org.apache.dubbo.config.RegistryConfig#0, content : Root bean: class [org.apache.dubbo.config.RegistryConfig]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] has been registered.
2022-03-10 21:09:23.091  INFO 18292 --- [           main] o.s.c.a.ConfigurationClassPostProcessor  : Cannot enhance @Configuration bean definition 'org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2022-03-10 21:09:23.434  INFO 18292 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-03-10 21:09:23.442  INFO 18292 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-03-10 21:09:23.442  INFO 18292 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.58]
2022-03-10 21:09:23.521  INFO 18292 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-03-10 21:09:23.521  INFO 18292 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3187 ms
2022-03-10 21:09:23.612  WARN 18292 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.longtong.service.StudentService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=), @org.apache.dubbo.config.annotation.DubboReference(cluster=, methods=[], lazy=false, listener=[], loadbalance=, callbacks=0, onconnect=, timeout=0, layer=, protocol=, reconnect=, ondisconnect=, stub=, client=, id=, tag=, interfaceName=, consumer=, connections=0, validation=, group=, owner=, init=false, registry=[], cache=, module=, injvm=true, monitor=, check=true, services=[], stubevent=false, version=1.0, actives=0, sent=false, generic=false, url=, filter=[], proxy=, retries=2, async=false, interfaceClass=interface com.longtong.service.StudentService, application=, sticky=false, mock=, parameters=[], merger=)}
2022-03-10 21:09:23.612  INFO 18292 --- [           main] f.a.ReferenceAnnotationBeanPostProcessor : class org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!
2022-03-10 21:09:23.614  INFO 18292 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-03-10 21:09:23.625  INFO 18292 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-03-10 21:09:23.643 ERROR 18292 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'com.longtong.service.StudentService' that could not be found.


Action:

Consider defining a bean of type 'com.longtong.service.StudentService' in your configuration.

 Obviously, the service class was not successfully called under the control layer class. My first consideration is that the configuration file may scan the package path incorrectly. After repeated inspections, it was found that there was no problem, and then a few hours passed. . . . . . . . . . .

DubboReference injects remote service objects as objects in the spring container. Resource and Autowired inject objects in the local spring container. So @Resource cannot be used here, and it is repeated here, so delete this line. 

Finally, I slapped myself.

Guess you like

Origin blog.csdn.net/m0_57545353/article/details/123411888