当前位置:网站首页>Field queryIndexFieldnameService in xxxImpl required a single bean, but 19 were found:
Field queryIndexFieldnameService in xxxImpl required a single bean, but 19 were found:
2022-06-11 21:03:00 【qq_ twenty-one million four hundred and eighty thousand three h】
Because of the actual needs of the project , That is, multiple classes implement the same interface , Different strategies take different Service Implementation class .
Interface class code :
public interface IQueryIndexFieldnameService {
Object queryIndexByFieldname(IndexDictionaryCoreDTO dto);
}
Because in the project , Because of 10 Multiple classes implement the interface at the same time , In the use of spring Automatic injection , The project fails to start because there are multiple instances reporting an error .
Error report detailed log :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-06-04 22:04:05.001 ERROR 30773 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field queryIndexFieldnameService in com.otitan.forest.inspector.dm.service.impl.QueryIndexServiceImpl required a single bean, but 19 were found:
- featureForestryIndustryOverview: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/FeatureForestryIndustryOverviewServiceImpl.class]
- forestGrassWetlandResource: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/ForestGrassWetlandResourceServiceImpl.class]
- forestLandClassifiedArea: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/ForestLandClassifiedAreaServiceImpl.class]
- forestryGrasslandPestControlOverview: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/ForestryGrasslandPestControlOverviewServiceImpl.class]
- forestryIndustryOverview: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/ForestryIndustryOverviewServiceImpl.class]
- landGreeningForestCultivationOverview: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/LandGreeningForestCultivationOverviewServiceImpl.class]
- nationForestFarmSeedlingDevelopmentOverviewForest: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/NationForestFarmSeedlingDevelopmentOverviewForestServiceImpl.class]
- nationForestFarmSeedlingDevelopmentOverviewSeedling: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/NationForestFarmSeedlingDevelopmentOverviewSeedlingServiceImpl.class]
- nationForestFarmSeedlingDevelopmentOverview: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/NationForestFarmSeedlingDevelopmentOverviewServiceImpl.class]
- nationReserveForestConstructionOverview: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/NationReserveForestConstructionOverviewServiceImpl.class]
- naturalForestProtectionForesterOverviewForest: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/NaturalForestProtectionForesterOverviewForestServiceImpl.class]
- naturalForestProtectionForesterOverviewPerson: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/NaturalForestProtectionForesterOverviewPersonServiceImpl.class]
- naturalForestProtectionForesterOverview: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/NaturalForestProtectionForesterOverviewServiceImpl.class]
- natureReserveOverviewDistribution: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/NatureReserveOverviewDistributionServiceImpl.class]
- natureReserveOverview: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/NatureReserveOverviewServiceImpl.class]
- publicWelfareForestConstructionOverview: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/PublicWelfareForestConstructionOverviewServiceImpl.class]
- worldNaturalHeritageWildlifeResourceOverviewPlace: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/WorldNaturalHeritageWildlifeResourceOverviewPlaceServiceImpl.class]
- worldNaturalHeritageWildlifeResourceOverview: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/WorldNaturalHeritageWildlifeResourceOverviewServiceImpl.class]
- worldNaturalHeritageWildlifeResourceOverviewSpecies: defined in file [/Users/carter/Desktop/firm/GzForestInspection/dynamic-monitor/target/classes/com/otitan/forest/inspector/dm/service/impl/WorldNaturalHeritageWildlifeResourceOverviewSpeciesServiceImpl.class]
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
Process finished with exit code 1
Solution :
1. Do not inject directly IQueryIndexFieldnameService, That is, do not use the following injection code
@Autowired
private IQueryIndexFieldnameService queryIndexFieldnameService;
2. Use the following injection code
@Autowired
private ApplicationContext applicationContext;
perhaps
@Autowired
private BeanFactory beanFactory;
3. obtain Bean The instance
// check bean Whether there is
if (!applicationContext.containsBean(dto.getTypeCode())) {
return null;
}
Object object = ((IQueryIndexFieldnameService)applicationContext.getBean(dto.getTypeCode())).queryIndexByFieldname(dto);
if (object == null) {
return null;
}
Relevant big data learning demo Address :
https://github.com/carteryh/big-data
边栏推荐
- 15 r exercise
- Title does not display after toolbar replaces actionbar
- Release of version 5.6 of rainbow, add multiple installation methods, and optimize the topology operation experience
- 为什么100G网络传输要使用iWARP、RoCE v2、NVMe-oF等协议
- Release of version 5.6 of rainbow, add multiple installation methods, and optimize the topology operation experience
- 周刊02|不瞞你說,我其實是MIT的學生
- Network security Kali penetration learning introduction to web penetration using MSF penetration to attack win7 host and execute commands remotely
- Why is your LDO output unstable?
- In idea, run the yarn command to show that the file cannot be loaded because running scripts is disabled on this system
- Teach you how to grab ZigBee packets through cc2531 and parse encrypted ZigBee packets
猜你喜欢

ORA-04098: trigger ‘xxx.xxx‘ is invalid and failed re-validation

应用场景:现场直播节目制作NDI技术中PoE网卡的广泛应用

输入值“18-20000hz”错误,设置信息不完整,请选择单位

10 R vector operation construction

One article to show you how to understand the harmonyos application on the shelves

Live broadcast with practice | 30 minutes to build WordPress website with Alibaba cloud container service and container network file system
![[nk] deleted number of 100 C Xiaohong in Niuke practice match](/img/f1/a99600e1800c087aceb60a559dee39.png)
[nk] deleted number of 100 C Xiaohong in Niuke practice match

周刊02|不瞒你说,我其实是MIT的学生

【数据可视化】Apache Superset 1.2.0教程 (二)——快速入门(可视化王者英雄数据)

Date of SQL optimization_ Format() function
随机推荐
Vectordrawable error
PHP strtotime 获取自然月误差问题解决方案
周刊02|不瞒你说,我其实是MIT的学生
Which Bluetooth headset is better within 500? Inventory of gifts for girls' Day
Cuckoo Hash
Yintai department store and Taobao tmall jointly create a green fashion show to help "carbon neutrality"
var 和 let的区别_let 和 var的区别
Why should I use iwarp, roce V2, nvme of and other protocols for 100g network transmission
UDP、TCP
Network security Kali penetration learning introduction to web penetration using MSF penetration to attack win7 host and execute commands remotely
解决 img 5px 间距的问题
【数据可视化】Apache Superset 1.2.0教程 (三)—— 图表功能详解
IDEA中,运行yarn命令,显示无法加载文件,因为在此系统上禁用运行脚本
正则校验匹配[0-100]、[0-1000]之间的正整数或小数点位数限制
9 r remove missing values
电竞网咖用2.5G网卡,体验飞一般的感觉!
RANSAC提取圆柱(MATLAB内置函数)
Serval and Rooted Tree(CF1153D)-DP
ubantu1804 两个opencv版本共存
使用 float 创建一个网页页眉、页脚、左边的内容和主要内容。