Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type

本文解决了一个Spring应用中因无法找到特定Mapper而导致的依赖注入失败问题,通过调整配置成功解决了异常。

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ypxxServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private yycg.business.dao.mapper.YpxxMapperCustom yycg.business.service.impl.YpxxServiceImpl.ypxxMapperCustom; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [yycg.business.dao.mapper.YpxxMapperCustom] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private yycg.business.dao.mapper.YpxxMapperCustom yycg.business.service.impl.YpxxServiceImpl.ypxxMapperCustom; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [yycg.business.dao.mapper.YpxxMapperCustom] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:513)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:92)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
    ... 22 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [yycg.business.dao.mapper.YpxxMapperCustom] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:947)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:816)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:730)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:485)
    ... 24 more

 

Business下的mapper无法扫描到,修改applicationContext-base-dao.xml扫描器配置:

Start Rapid Server ... [StatService, BaffleService, ssGenClientKeyService, ssChapVerifyService, ssDFACloseService, ssDFAEnableService, ssDFAGetSRandService, ssDFAGetStatusService, ssDFAVerifyService, ssDFPRandomService, ssDFPVerifyService, ssDestroyService, ssDisableService, ssEnableService, ssGetActiveCodeService, ssGetCHAP2RandomCodeService, ssGetCHAP2VerifyCodeService, ssGetChallCodeService, ssGetChlgCodeService, ssGetPUKService, ssGetSmsOtpService, ssGetSmsTokenService, ssGetTokenPwdService, ssGetUUKService, ssLostService, ssMBEnableService, ssMBGetActivateCodeService, ssQueryService, ssRettkService, ssSM2CertificateApplicationDownloadService, ssSM2CertificateQueryService, ssSM2CertificateRevocationService, ssSM2CertificateUpdateService, ssSM4SecureRandomService, ssSM2VerifySignByP7Service, ssSM2deviceInformationDeletionService, ssSM2gainRandomFactorService, ssSM2modifyServUserPinService, ssSM2servGenSM2PartPrikeyService, ssSM2servPartDecryptByThresholdKeyService, ssSM2servPartSignByThresholdKeyService, ssSM2verifySigBySM2PubkeyService, ssSMSCheckService, ssSMSCloseAllService, ssSMSCloseService, ssSMSEnableService, ssSMSLoginService, ssSMSPCDeleteService, ssSMSPCQueryService, ssSMSRandomService, ssSMSSelectAllService, ssSMSVerifyPayService, ssServerManagerService, ssSetPinService, ssSyncService, ssSysPhoneService, ssUnlockService, ssUnlostService, ssVPRDeleteService, ssVPRQueryService, ssVPRRandomService, ssVPRRegistService, ssVPRVerifyService, ssVerifyService] Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceContext' defined in class path resource [conf/service-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ssGenClientKeyService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.higinet.security.util.Conf cn.com.higinet.security.service.ext.GenClientKeyService.ssConf; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ssconf': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.higinet.rapid.base.dao.BaseDao cn.com.higinet.security.util.Conf.essSSBaseDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [cn.com.higinet.rapid.base.dao.BaseDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) at cn.com.higinet.rapid.server.Bootstrap.main(Bootstrap.java:60) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ssGenClientKeyService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.higinet.security.util.Conf cn.com.higinet.security.service.ext.GenClientKeyService.ssConf; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ssconf': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.higinet.rapid.base.dao.BaseDao cn.com.higinet.security.util.Conf.essSSBaseDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [cn.com.higinet.rapid.base.dao.BaseDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079) at cn.com.higinet.rapid.server.core.ServiceContext.setApplicationContext(ServiceContext.java:41) at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:106) at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:85) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ... 11 more Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.higinet.security.util.Conf cn.com.higinet.security.service.ext.GenClientKeyService.ssConf; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ssconf': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.higinet.rapid.base.dao.BaseDao cn.com.higinet.security.util.Conf.essSSBaseDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [cn.com.higinet.rapid.base.dao.BaseDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282) ... 25 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ssconf': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.higinet.rapid.base.dao.BaseDao cn.com.higinet.security.util.Conf.essSSBaseDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [cn.com.higinet.rapid.base.dao.BaseDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474) ... 27 more Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.higinet.rapid.base.dao.BaseDao cn.com.higinet.security.util.Conf.essSSBaseDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [cn.com.higinet.rapid.base.dao.BaseDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282) ... 38 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [cn.com.higinet.rapid.base.dao.BaseDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
06-11
D:\UseApp\jdk1.8.0_101\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:65209,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:D:\UseApp\ideaIU-2020.1.1\plugins\java\lib\rt\debugger-agent.jar=file:/C:/Users/LEGION/AppData/Local/Temp/capture11.props -Dfile.encoding=UTF-8 -classpath C:\Users\LEGION\AppData\Local\Temp\classpath1154393012.jar com.bonc.activityGenerate.ActivityGenerateApplication Connected to the target VM, address: '127.0.0.1:65209', transport: 'socket' 2025-06-10 23:00:43.106 DEBUG 16796 --- [ main] c.a.n.client.env.SearchableProperties : properties search order:PROPERTIES->JVM->ENV 2025-06-10 23:00:43.230 DEBUG 16796 --- [ main] o.s.boot.SpringApplication : Loading source class org.springframework.cloud.bootstrap.BootstrapImportSelectorConfiguration 2025-06-10 23:00:43.253 DEBUG 16796 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4da855dd 2025-06-10 23:00:43.549 INFO 16796 --- [ main] c.a.n.p.a.s.c.ClientAuthPluginManager : [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.impl.NacosClientAuthServiceImpl success. 2025-06-10 23:00:43.549 INFO 16796 --- [ main] c.a.n.p.a.s.c.ClientAuthPluginManager : [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.ram.RamClientAuthServiceImpl success. 2025-06-10 23:00:43.903 DEBUG 16796 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase -2147483647 2025-06-10 23:00:43.903 DEBUG 16796 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Successfully started bean 'springBootLoggingLifecycle' 2025-06-10 23:00:43.907 DEBUG 16796 --- [ main] ConditionEvaluationReportLoggingListener : ============================ CONDITIONS EVALUATION REPORT ============================ Positive matches: ----------------- ConfigurationPropertiesRebinderAutoConfiguration matched: - @ConditionalOnBean (types: org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor; SearchStrategy: all) found bean 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor' (OnBeanCondition) ConfigurationPropertiesRebinderAutoConfiguration#configurationPropertiesBeans matched: - @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesBeans; SearchStrategy: current) did not find any beans (OnBeanCondition) ConfigurationPropertiesRebinderAutoConfiguration#configurationPropertiesRebinder matched: - @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder; SearchStrategy: current) did not find any beans (OnBeanCondition) EncryptionBootstrapConfiguration matched: - @ConditionalOnClass found required class 'org.springframework.security.crypto.encrypt.TextEncryptor' (OnClassCondition) EncryptionBootstrapConfiguration#keyProperties matched: - @ConditionalOnMissingBean (types: org.springframework.cloud.bootstrap.encrypt.KeyProperties; SearchStrategy: all) did not find any beans (OnBeanCondition) NacosConfigBootstrapConfiguration matched: - @ConditionalOnProperty (spring.cloud.nacos.config.enabled) matched (OnPropertyCondition) NacosConfigBootstrapConfiguration#nacosConfigManager matched: - @ConditionalOnMissingBean (types: com.alibaba.cloud.nacos.NacosConfigManager; SearchStrategy: all) did not find any beans (OnBeanCondition) NacosConfigBootstrapConfiguration#nacosConfigProperties matched: - @ConditionalOnMissingBean (types: com.alibaba.cloud.nacos.NacosConfigProperties; SearchStrategy: all) did not find any beans (OnBeanCondition) PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer matched: - @ConditionalOnMissingBean (types: org.springframework.context.support.PropertySourcesPlaceholderConfigurer; SearchStrategy: current) did not find any beans (OnBeanCondition) Negative matches: ----------------- EncryptionBootstrapConfiguration.RsaEncryptionConfiguration: Did not match: - Keystore nor key found in Environment (EncryptionBootstrapConfiguration.KeyCondition) Matched: - @ConditionalOnClass found required class 'org.springframework.security.rsa.crypto.RsaSecretEncryptor' (OnClassCondition) EncryptionBootstrapConfiguration.VanillaEncryptionConfiguration: Did not match: - @ConditionalOnMissingClass found unwanted class 'org.springframework.security.rsa.crypto.RsaSecretEncryptor' (OnClassCondition) NacosConfigBootstrapConfiguration#smartConfigurationPropertiesRebinder: Did not match: - @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder; SearchStrategy: current) found beans of type 'org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder' configurationPropertiesRebinder (OnBeanCondition) NacosDiscoveryClientConfigServiceBootstrapConfiguration: Did not match: - @ConditionalOnClass did not find required class 'org.springframework.cloud.config.client.ConfigServicePropertySourceLocator' (OnClassCondition) Exclusions: ----------- None Unconditional classes: ---------------------- None . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.6.11) 2025-06-10 23:00:46.022 INFO 16796 --- [ main] c.a.n.c.a.AbstractAbilityControlManager : Ready to get current node abilities... 2025-06-10 23:00:46.024 INFO 16796 --- [ main] c.a.n.c.a.AbstractAbilityControlManager : Ready to initialize current node abilities, support modes: [SDK_CLIENT] 2025-06-10 23:00:46.024 INFO 16796 --- [ main] c.a.n.c.a.AbstractAbilityControlManager : Initialize current abilities finish... 2025-06-10 23:00:46.025 INFO 16796 --- [ main] c.a.n.c.a.d.NacosAbilityManagerHolder : [AbilityControlManager] Successfully initialize AbilityControlManager 2025-06-10 23:00:46.145 DEBUG 16796 --- [ main] o.s.boot.env.OriginTrackedYamlLoader : Loading from YAML: Byte array resource [redisson-service-prod.yml] 2025-06-10 23:00:46.151 DEBUG 16796 --- [ main] o.s.boot.env.OriginTrackedYamlLoader : Merging document (no matchers set): {spring={mvc={pathmatch={matching-strategy=ANT_PATH_MATCHER}}, http={multipart={enabled=true, max-file-size=-1, max-request-size=-1}}, datasource={dynamic={primary=tri, strict=false, datasource={tri={driver-class-name=com.mysql.jdbc.Driver, url=jdbc:mysql://172.16.50.128:8921/sdiri_db?useSSL=false&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai, username=e_sdiri, password=uHF4CiXAMR5pe3AL, type=com.zaxxer.hikari.HikariDataSource, hikari={maximum-pool-size=40, minimum-idle=1, idle-timeout=30000, connection-timeout=30000, max-lifetime=1800000, pool-name=MyAppPool}}}}}}, tri={activityServerUrl=http://172.16.50.140:30913, activityEditUrl=http://172.16.50.140:30913/bloc-web/#/activity/edit/index/, AIGCGenerateImgServerUrl=http://172.16.20.29:30804/sd-api, standardServerUrl=http://10.135.139.99:30753, yunXiActivityDescUrl=/anlikuHtml/caselibrary.html#/caseIndexSSO, llmServerUrl=http://10.218.27.125:30871, llmModelName=Qwen2.5-32B-Instruct}, logging={config=classpath:logback-spring.xml}, feign={httpclient={max-connections-per-route=200, max-connections=1000}, circuitbreaker={enabled=true}, client={config={default={connect-timeout=300000, read-timeout=300000}}}}, server={port=31963, servlet={context-path=/act}}, login={skipUrls=[/user/login, /user/getLoginCode, /user/register, /task/logWebsocket, /server/**/api/chat, /wsApiChat, /server/serverDesc/**, /server/openServerList, /server/aiCloudPhone/**, /open/jiKe/**, /**/*.html, /**/*.js, /**/*.css, /**/*.icon, /**/*.gif, /**/*.jpg, /**/*.png, /chat/**, /swagger-resources/**, /v2/]}} 2025-06-10 23:00:46.151 DEBUG 16796 --- [ main] o.s.boot.env.OriginTrackedYamlLoader : Loaded 1 document from YAML resource: Byte array resource [redisson-service-prod.yml] 2025-06-10 23:00:46.163 WARN 16796 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[redisson-service] & group[DEFAULT_GROUP] 2025-06-10 23:00:46.172 WARN 16796 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[redisson-service.yml] & group[DEFAULT_GROUP] 2025-06-10 23:00:46.334 DEBUG 16796 --- [ main] o.s.boot.env.OriginTrackedYamlLoader : Loading from YAML: Byte array resource [redisson-service-prod.yml] 2025-06-10 23:00:46.339 DEBUG 16796 --- [ main] o.s.boot.env.OriginTrackedYamlLoader : Merging document (no matchers set): {spring={mvc={pathmatch={matching-strategy=ANT_PATH_MATCHER}}, http={multipart={enabled=true, max-file-size=-1, max-request-size=-1}}, datasource={dynamic={primary=tri, strict=false, datasource={tri={driver-class-name=com.mysql.jdbc.Driver, url=jdbc:mysql://172.16.50.128:8921/sdiri_db?useSSL=false&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai, username=e_sdiri, password=uHF4CiXAMR5pe3AL, type=com.zaxxer.hikari.HikariDataSource, hikari={maximum-pool-size=40, minimum-idle=1, idle-timeout=30000, connection-timeout=30000, max-lifetime=1800000, pool-name=MyAppPool}}}}}}, tri={activityServerUrl=http://172.16.50.140:30913, activityEditUrl=http://172.16.50.140:30913/bloc-web/#/activity/edit/index/, AIGCGenerateImgServerUrl=http://172.16.20.29:30804/sd-api, standardServerUrl=http://10.135.139.99:30753, yunXiActivityDescUrl=/anlikuHtml/caselibrary.html#/caseIndexSSO, llmServerUrl=http://10.218.27.125:30871, llmModelName=Qwen2.5-32B-Instruct}, logging={config=classpath:logback-spring.xml}, feign={httpclient={max-connections-per-route=200, max-connections=1000}, circuitbreaker={enabled=true}, client={config={default={connect-timeout=300000, read-timeout=300000}}}}, server={port=31963, servlet={context-path=/act}}, login={skipUrls=[/user/login, /user/getLoginCode, /user/register, /task/logWebsocket, /server/**/api/chat, /wsApiChat, /server/serverDesc/**, /server/openServerList, /server/aiCloudPhone/**, /open/jiKe/**, /**/*.html, /**/*.js, /**/*.css, /**/*.icon, /**/*.gif, /**/*.jpg, /**/*.png, /chat/**, /swagger-resources/**, /v2/]}} 2025-06-10 23:00:46.339 DEBUG 16796 --- [ main] o.s.boot.env.OriginTrackedYamlLoader : Loaded 1 document from YAML resource: Byte array resource [redisson-service-prod.yml] 2025-06-10 23:00:46.341 INFO 16796 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource@1176254217 {name='bootstrapProperties-redisson-service-prod.yml,DEFAULT_GROUP', properties={spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER, spring.http.multipart.enabled=true, spring.http.multipart.max-file-size=-1, spring.http.multipart.max-request-size=-1, spring.datasource.dynamic.primary=tri, spring.datasource.dynamic.strict=false, spring.datasource.dynamic.datasource.tri.driver-class-name=com.mysql.jdbc.Driver, spring.datasource.dynamic.datasource.tri.url=jdbc:mysql://172.16.50.128:8921/sdiri_db?useSSL=false&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai, spring.datasource.dynamic.datasource.tri.username=e_sdiri, spring.datasource.dynamic.datasource.tri.password=uHF4CiXAMR5pe3AL, spring.datasource.dynamic.datasource.tri.type=com.zaxxer.hikari.HikariDataSource, spring.datasource.dynamic.datasource.tri.hikari.maximum-pool-size=40, spring.datasource.dynamic.datasource.tri.hikari.minimum-idle=1, spring.datasource.dynamic.datasource.tri.hikari.idle-timeout=30000, spring.datasource.dynamic.datasource.tri.hikari.connection-timeout=30000, spring.datasource.dynamic.datasource.tri.hikari.max-lifetime=1800000, spring.datasource.dynamic.datasource.tri.hikari.pool-name=MyAppPool, tri.activityServerUrl=http://172.16.50.140:30913, tri.activityEditUrl=http://172.16.50.140:30913/bloc-web/#/activity/edit/index/, tri.AIGCGenerateImgServerUrl=http://172.16.20.29:30804/sd-api, tri.standardServerUrl=http://10.135.139.99:30753, tri.yunXiActivityDescUrl=/anlikuHtml/caselibrary.html#/caseIndexSSO, tri.llmServerUrl=http://10.218.27.125:30871, tri.llmModelName=Qwen2.5-32B-Instruct, logging.config=classpath:logback-spring.xml, feign.httpclient.max-connections-per-route=200, feign.httpclient.max-connections=1000, feign.circuitbreaker.enabled=true, feign.client.config.default.connect-timeout=300000, feign.client.config.default.read-timeout=300000, server.port=31963, server.servlet.context-path=/act, login.skipUrls[0]=/user/login, login.skipUrls[1]=/user/getLoginCode, login.skipUrls[2]=/user/register, login.skipUrls[3]=/task/logWebsocket, login.skipUrls[4]=/server/**/api/chat, login.skipUrls[5]=/wsApiChat, login.skipUrls[6]=/server/serverDesc/**, login.skipUrls[7]=/server/openServerList, login.skipUrls[8]=/server/aiCloudPhone/**, login.skipUrls[9]=/open/jiKe/**, login.skipUrls[10]=/**/*.html, login.skipUrls[11]=/**/*.js, login.skipUrls[12]=/**/*.css, login.skipUrls[13]=/**/*.icon, login.skipUrls[14]=/**/*.gif, login.skipUrls[15]=/**/*.jpg, login.skipUrls[16]=/**/*.png, login.skipUrls[17]=/chat/**, login.skipUrls[18]=/swagger-resources/**, login.skipUrls[19]=/v2/}}, BootstrapPropertySource@132372445 {name='bootstrapProperties-redisson-service.yml,DEFAULT_GROUP', properties={}}, BootstrapPropertySource@1063494931 {name='bootstrapProperties-redisson-service,DEFAULT_GROUP', properties={}}] _ _ |_ _ _|_. ___ _ | _ | | |\/|_)(_| | |_\ |_)||_|_\ / | 3.4.1 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosLoadBalancer' defined in class path resource [com/alibaba/cloud/nacos/loadbalancer/NacosLoadBalancerClientConfiguration.class]: Unsatisfied dependency expressed through method 'nacosLoadBalancer' parameter 2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.alibaba.cloud.nacos.NacosDiscoveryProperties' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:745) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:420) at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) at com.bonc.activityGenerate.ActivityGenerateApplication.main(ActivityGenerateApplication.java:40) Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.alibaba.cloud.nacos.NacosDiscoveryProperties' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ... 19 more Disconnected from the target VM, address: '127.0.0.1:65209', transport: 'socket' Process finished with exit code 0 项目启动失败的原因是什么?怎么解决?
06-11
### 问题分析 在 Spring 应用中,出现 `NoSuchBeanDefinitionException` 异常通常表示容器无法找到指定名称或类型的 Bean。具体到当前问题,异常信息为: ``` Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'bus' available ``` 这意味着 Spring 容器在启动过程中尝试解析名为 `bus` 的 Bean 时失败,可能的原因包括: - **未正确声明名为 `bus` 的 Bean**:例如在 Apache CXF 配置中未定义 `<cxf:bus>` 标签,导致默认的 Bus 实例未被注册。 - **命名空间配置不完整或错误**:Spring XML 配置文件中缺少对 CXF 命名空间的引用,导致 `<cxf:bus>` 无法识别。 - **依赖缺失或版本冲突**:项目中缺少必要的 CXF 依赖,或者存在多个版本的冲突,导致容器无法加载相关类。 - **IDE 缓存问题**:有时即使配置正确,IDE 可能仍显示错误提示,实际运行时也可能抛出该异常。 --- ### 解决方案 #### 1. 确保 `bus` Bean 被正确定义 Apache CXF 提供了 `<cxf:bus>` 标签用于自动注册一个名为 `bus` 的 Bean。只要在配置文件中正确使用该标签,即可直接通过 `ref="bus"` 引用它: ```xml <cxf:bus> <cxf:features> <cxf:logging/> </cxf:features> </cxf:bus> ``` 此配置会注册一个名为 `bus` 的 Bean,确保其他组件可以引用它[^2]。 #### 2. 检查命名空间和 Schema 地址 确保 XML 文件头部包含正确的命名空间声明及对应的 schemaLocation,尤其是针对 CXF 的部分: ```xml xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd" ``` 只有在命名空间和 schemaLocation 正确的情况下,CXF 的标签才能被正确解析并注册为 Bean。 #### 3. 添加必要的 Maven 依赖 如果项目中缺少 CXF 的核心依赖,即使配置正确,Spring 容器也无法加载 `bus` Bean。请确保在 `pom.xml` 中添加如下依赖: ```xml <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-core</artifactId> <version>3.6.2</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>3.6.2</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>3.6.2</version> </dependency> ``` 这些依赖是使用 CXF 功能所必需的,缺少它们会导致运行时找不到 Bean[^2]。 #### 4. 清理 IDE 缓存并重新加载依赖 有时即使配置完全正确,IDE 可能仍然标红某些标签或报错。此时应尝试执行以下操作: - 在 Maven 项目中运行 `mvn clean install` 以确保所有依赖已正确下载。 - 重启 IDE 并清除缓存(例如,在 IntelliJ 中可通过 `File > Invalidate Caches / Restart` 实现)。 - 重新导入项目以确保 XML 配置文件被正确解析。 --- ### 示例完整配置 以下是一个完整的 Spring XML 配置示例,确保 `bus` Bean 被正确注册并可被引用: ```xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"> <cxf:bus> <cxf:features> <cxf:logging/> </cxf:features> </cxf:bus> <bean id="helloWorldEndpoint" class="org.apache.cxf.jaxws.EndpointImpl"> <constructor-arg ref="bus"/> <constructor-arg ref="helloWorld"/> <property name="address" value="/HelloWorld"/> </bean> <bean id="helloWorld" class="com.example.HelloWorldImpl"/> </beans> ``` ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值