An implementation of ImportBeanDefinitionRegistrar can be specified with @Import so that additional objects can be registered as Spring beans during configuration time.
public class MyBeanRegistrar implements ImportBeanDefinitionRegistrar {
@Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { //there can be some conditional criteria to add the following bean GenericBeanDefinition gbd = new GenericBeanDefinition(); gbd.setBeanClass(AppBean.class); gbd.getPropertyValues().addPropertyValue("str", "value set from registrar"); registry.registerBeanDefinition("appBean", gbd); } }