以下是我的弹簧配置。
<bean id="taskThreadExecutor" class="org.springframework.scheduling.concurrent.ConcurrentTaskExecutor">
<property name="concurrentExecutor" ref="threadPoolExecutor" />
</bean>
<bean id="threadPoolExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="100" />
<property name="maxPoolSize" value="200" />
<property name="queueCapacity" value="300" />
</bean>
<bean id="concurrentTaskExecutor" class="org.springframework.scheduling.concurrent.ConcurrentTaskExecutor" scope="prototype">
<qualifier value="rmsTaskExecutor"></qualifier>
<property name="concurrentExecutor">
<bean class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="400" />
<property name="maxPoolSize" value="600" />
<property name="queueCapacity" value="3000" />
</bean>
</property>
</bean>
在我班上,我按如下方式进行布线
@Autowired
@qualifier("rmsTaskExecutor")
private ConcurrentTaskExecutor concurrentTaskExecutor;
在运行时。,我得到以下异常。,说没有类型的唯一bean。
嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有 独特的豆类 [org.springframework.scheduling.concurrent.ConcurrentTaskExecutor]是 已定义:预期单个匹配bean但找到2: [taskThreadExecutor,concurrentTaskExecutor]
Dunnow在哪里和我错过了什么。我使用的是spring 3.0.x版本
答案 0 :(得分:1)
是正常的,你有2个ConcurrentTaskExecutor(taskThreadExecutor和concurrentTaskExecutor)所以尝试使用@Resource(..)