Affects: 5.1.9
At the moment it is possible to register beans using @Bean annotation. As far I know each bean registered in such way need its own method so it is impossible to register variable number of beans based on configuration or other dynamic mechanism.
Once there is a need for dynamic bean registration one have to abandon java configuration in favor of BeanFactoryPostProcessor or BeanDefinitionRegistryPostProcessor.
It would be great to be able to register variable number of beans at once using java configuration.
Sample solution could be to have @Beans annotation that decorates methods returning arrays, collections or maps and instead of registering the whole container as a bean it registers each item separately.
The names of the beans could be auto-generated (like <methodName>#<index>) or somehow provided by the programmer (map keys, SpEL expression to evaluate against bean).
Comment From: sbrannen
It is already possible to programmatically register beans in Java Config class via the various registerBean() methods in the application context.
For some examples, check out this blog.
I am therefore closing this issue.
Comment From: Azbesciak
It is sad that you are not going to provide that