No qualifying bean of type 'com.alibaba.dubbo.config.ApplicationConfig' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
猜测原因是:实例化类是,zk部署在一台服务器,Service调用重名但是却部署到了俩台服务器导致同一个API,俩台服务器依赖调用,同时是服务名相同,但是项目名称不一样导致!
改动,实例化类的名称进行修改掉,比如此处的:【name 'dupNewsController'】暂时性的还是后续报错!
应该是缓存没有清空!
其他解决办法:启动的时候注入实例化:
import com.alibaba.dubbo.config.ApplicationConfig;
import com.datadevelopment.middle.auth.common.ShiroConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@Slf4j
@SpringBootApplication(scanbasePackages = {ShiroConstant.AUTH_PACKAGE, "com.datadevelopment.npp"})
public class NppWebApplication {
public static void main(String[] args) {
try {
// 应用配置信息
ApplicationConfig application = new ApplicationConfig("news-production-platform-web");
// 版本号
application.setVersion("2021.10.27.1");
// 负责人
application.setOwner("loveyouforever");
// 组织名称
application.setOrganization("test_organization");
// 环境
application.setEnvironment("test");
// 字节码编译器
application.setCompiler("javassist");
SpringApplication.run(NppWebApplication.class, args);
log.info("the service npp-web started!");
log.error("正常启动完成");
} catch (Exception e) {
log.error("the service npp-web start failed, the exception: {}", e);
}
}
}
还有把应用名称在项目中进行配置 YML
application: name: news-production-platform-web
spring:
profiles:
include: dao
redis:
database: 0
host: 127.0.0.1
port: 6379
timeout: 3000
jedis:
pool:
max-active: -1
max-wait: -1
max-idle: 8
min-idle: 3
application:
name: news-production-platform-web
dubbo:
application:
name: news-production-platform-web
redis:
address: redis://127.0.0.1:6379
app:
name: npp-web
group: tbm-dev
registry:
address: 127.0.0.1:2181
rpc:
protocol:
name: dubbo
monitor:
enable: true
trace:
log: false
management:
endpoints:
web:
exposure:
include: "*"
base-path: /
endpoint:
health:
show-details: always
httptrace: true
shutdown:
enabled: true
server:
port: 8081
server:
port: 9002
servlet:
context-path: /npp
logback:
fileDir: /home/program/npp/npp-web/log/daily
level: ERROR
logging:
config: classpath:logback-spring.xml
然后maven-install上传到xshell之后运行目前是正常的:
启动命令:
nohup java -Xms512m -Xmx512m -Xrunjdwp:transport=dt_socket,address=9013,server=y,suspend=n -jar /home/program/npp/npp-web/npp*.jar > /home/program/npp/npp-web/log/npp.log 2>&1 &
021-10-27 16:22:13.251|ERROR|main|826|o.s.boot.SpringApplication :Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dupNewsController' defined in URL [jar:file:/home/program/npp/npp-web/npp-web-1.0.0-SNAPSHOT.jar!/BOOT-INF/classes!/comjrescloud/rpc/def/RpcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'consumerConfig' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.alibaba.dubbo.config.ApplicationConfig' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at com.*.datadevelopment.npp.NppWebApplication.main(NppWebApplication.java:14)
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:51)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: org.springframework.beans.factory.BeanInitializationException: Failed to init remote service reference at filed tbmDupNewsFacade in class com.*.datadevelopment.npp.web.controller.news.DupNewsController; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'consumerConfig' defined in class path resource [comjrescloud/rpc/def/RpcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'consumerConfig' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.alibaba.dubbo.config.ApplicationConfig' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}



