RAZE Olivier opened SPR-13430 and commented
Hi,
I have defined two beans with same class: org.springframework.scheduling.quartz.SchedulerFactoryBean but with different id;
when i want inject a bean i write @Resource
(name="id1") and i have this error:
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'id1' must be of type [org.springframework.scheduling.quartz.SchedulerFactoryBean], but was actually of type [org.quartz.impl.StdScheduler]
if i write @Autowired
@Qualifer
('id1') there is no error.
PS: Sorry for my english
Affects: 3.2.3
Comment From: spring-projects-issues
Juergen Hoeller commented
Looks like the FactoryBean
isn't consistently resolved there, with the algorithm suddenly encountering the resolved object versus the original FactoryBean... and getting confused at that point.
Have you tried this against a more recent Spring Framework version, e.g. 3.2.14 or (ideally) 4.2.1? The resolution algorithm has been fine-tuned several times, so the problem might be resolved in the meantime.
If it still fails for you against a recent version, please try to create a reproducible test case for it. We haven't encountered this before, so it might be caused by some subtle specifics in your setup.
Juergen
Comment From: guosx2015
FactoryBean that creates and configures a Quartz Scheduler, manages its lifecycle as part of the Spring application context, and exposes the Scheduler as bean reference for dependency injection. messages above is from spring-context-support‘s document,this has expained why the error is ocurred。