Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Bean definitions using indexed constructor arguments are not usable for @Autowired resolution [SPR-11019] #15647
I created some bean definitions in my BeanRegistry and was using indexed constructor arguments.
We traced it down to:
line 635 of the AbstractAutowireCapableBeanFactory in the getTypeForFactoryMethod method
This code only looks for methods based on argument values set as GenericArgumentValues - any set via indexedArgumentValues are not found.
switching our code to create bean definitions using GenericArgumentValues instead of IndexedArgumentValues fixed the issue for us, but this seems like an oversight.
Changing it slightly to something like this should at least address this one case:
(feel free to use the above code - I've signed the spring contributor agreement... if you want I can do this on a branch and submit a pull request for it)
Juergen Hoeller commented
I've addressed this through following the same argument lookup algorithm that ConstructorResolver itself uses when invoking a constructor or factory method. Any mix of generic and indexed arguments and even named arguments should work now.