Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring:使用@Qualifier和基于注释的Spring配置_Java_Spring_Annotations - Fatal编程技术网

Java Spring:使用@Qualifier和基于注释的Spring配置

Java Spring:使用@Qualifier和基于注释的Spring配置,java,spring,annotations,Java,Spring,Annotations,如何将@Qualifier与基于注释的spring配置一起使用 我看到的示例使用的是基于xml的,需要id属性 先谢谢你 编辑: 如果我上面的问题不清楚,我很抱歉。下面是我尝试使用@Qualifier+基于注释的配置 @Bean(name="explorerTableList") ObservableList<ExplorerTableAdapter> explorerTableList() { return FXCollections.observableArrayList

如何将@Qualifier与基于注释的spring配置一起使用

我看到的示例使用的是基于xml的,需要id属性

先谢谢你

编辑:

如果我上面的问题不清楚,我很抱歉。下面是我尝试使用@Qualifier+基于注释的配置

@Bean(name="explorerTableList")
ObservableList<ExplorerTableAdapter> explorerTableList() {
    return FXCollections.observableArrayList();
}
@Bean(name=“explorerTableList”)
ObservableList explorerTableList(){
返回FXCollections.observableArrayList();
}
在我的构造函数中

@Autowired
public ExplorerTableGlassImpl(

    @Qualifier("explorerTableList")
    ObservableList<ExplorerTableAdapter> list

) {

    super( ExplorerTableAdapter.class, list );
}
@Autowired
公共探索者表格GlassImpl(
@限定符(“explorerTableList”)
可观察列表
) {
super(ExplorerTableAdapter.class,list);
}
例外情况:

Exception in thread "main" java.lang.RuntimeException: Exception in Application init method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'facilitiesExplorerFormImpl': Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'explorerTableGlassImpl' defined in file [D:\git\chartstream\ChartStream3-Facilities\target\classes\com\hccs\chartstream\facilities\x\explorertable\ExplorerTableGlassImpl.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [javafx.collections.ObservableList]: : No qualifying bean of type [com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter] found for dependency [collection of com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=explorerTableList)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter] found for dependency [collection of com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=explorerTableList)}
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
    at com.hccs.chartstream.facilities.ModuleContext.initialize(ModuleContext.java:23)
    at com.hccs.chartstream.facilities.FacilitiesInit.init(FacilitiesInit.java:20)
    at com.hccs.platform.PlatformApplication.lambda$0(PlatformApplication.java:57)
    at java.lang.Iterable.forEach(Unknown Source)
    at com.hccs.platform.PlatformApplication.initializeModules(PlatformApplication.java:55)
    at com.hccs.platform.PlatformApplication.init(PlatformApplication.java:43)
    ... 3 more
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'explorerTableGlassImpl' defined in file [D:\git\chartstream\ChartStream3-Facilities\target\classes\com\hccs\chartstream\facilities\x\explorertable\ExplorerTableGlassImpl.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [javafx.collections.ObservableList]: : No qualifying bean of type [com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter] found for dependency [collection of com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=explorerTableList)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter] found for dependency [collection of com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=explorerTableList)}
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:747)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1114)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1017)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
    at com.hccs.chartstream.core.ui.base.classes.FormBase.setupContext(FormBase.java:48)
    at com.hccs.chartstream.core.ui.base.classes.FormBase.init(FormBase.java:39)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
    ... 21 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter] found for dependency [collection of com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=explorerTableList)}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1103)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:915)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:811)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:739)
    ... 43 more
线程“main”java.lang.RuntimeException中的异常:应用程序初始化方法中的异常
位于com.sun.javafx.application.LaunchImpl.launchApplication1(未知源)
位于com.sun.javafx.application.launchempl.lambda$launchApplication$156(未知来源)
位于java.lang.Thread.run(未知源)
原因:org.springframework.beans.factory.BeanCreationException:创建名为“FacilitieExplorerFormImpl”的bean时出错:调用init方法失败;嵌套异常为org.springframework.beans.factory.unsatifiedDependencyException:创建名为“explorerTableGlassImpl”的bean时出错,该bean在文件[D:\git\chartstream\ChartStream3 Facilities\target\classes\com\hccs\chartstream\Facilities\x\explorertable\explorerTableGlassImpl.class]中定义:通过构造函数参数表示的未满足的依赖项,索引0的类型为[javafx.collections.observeList]::未找到依赖项[com.hccs.chartream.facilities.x.explorertable.ExplorerTableAdapter]类型为[com.hccs.chartream.facilities.x.ExplorerTableAdapter]的合格bean:应至少有1个bean符合此依赖项的autowire候选项的条件。依赖项注释:{@org.springframework.beans.factory.annotation.Qualifier(value=explorerTableList)};嵌套异常为org.springframework.beans.factory.NoSuchBean定义异常:未找到依赖项[com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter]类型为[com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter]的符合条件的bean:应至少有1个bean符合此依赖项的autowire候选项的条件。依赖项注释:{@org.springframework.beans.factory.annotation.Qualifier(value=explorerTableList)}
位于org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)上
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
位于org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
位于org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
位于org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
位于org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
位于org.springframework.beans.factory.support.DefaultListableBeanFactory.PreInstanceSingleton(DefaultListableBeanFactory.java:703)
位于org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
位于org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
位于org.springframework.context.annotation.AnnotationConfigApplicationContext。(AnnotationConfigApplicationContext.java:84)
位于com.hccs.chartstream.facilities.ModuleContext.initialize(ModuleContext.java:23)
位于com.hccs.chartstream.facilities.FacilitiesInit.init(FacilitiesInit.java:20)
位于com.hccs.PlatformApplication.lambda$0(PlatformApplication.java:57)
位于java.lang.Iterable.forEach(未知源)
位于com.hccs.PlatformApplication.initializeModule(PlatformApplication.java:55)
位于com.hccs.PlatformApplication.init(PlatformApplication.java:43)
... 3个以上
原因:org.springframework.beans.factory.unsatifiedDependencyException:创建名为“explorerTableGlassImpl”的bean时出错,该名称在文件[D:\git\chartstream\ChartStream3 Facilities\target\classes\com\hccs\chartstream\Facilities\x\explorertable\explorerTableGlassImpl.class]中定义:通过构造函数参数表示的未满足的依赖项,索引0的类型为[javafx.collections.observeList]::未找到依赖项[com.hccs.chartream.facilities.x.explorertable.ExplorerTableAdapter]类型为[com.hccs.chartream.facilities.x.ExplorerTableAdapter]的合格bean:应至少有1个bean符合此依赖项的autowire候选项的条件。依赖项注释:{@org.springframework.beans.factory.annotation.Qualifier(value=explorerTableList)};嵌套异常为org.springframework.beans.factory.NoSuchBean定义异常:未找到依赖项[com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter]类型为[com.hccs.chartstream.facilities.x.explorertable.ExplorerTableAdapter]的符合条件的bean:应至少有1个bean符合此依赖项的autowire候选项的条件。依赖项注释:{@org.springframework.beans.factory.annotation.Qualifier(value=explorer