dynamically registered my custom bean using the below method but the @auotwired, @value, and @import annotations are not invoked after initialization.

@Import(value = { DB.class, Sftp.class, Message.class })
public class SFTPConfiguration {

}

class DB {

@Autowrite
Sftp sftp

@Value("${my.db.user}")
String dbUser

}

class Sftp {

@Autowrite
Message message

@Value("${my.sftp.user}")
String sftpUser

}

class Message {
}

public static void registerBean(ApplicationContext context, String beanName, Class<?> beanClass) {
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) context.getAutowireCapableBeanFactory();
    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
    beanDefinition.setBeanClass(beanClass);
    registry.registerBeanDefinition(beanName, beanDefinition);

}

registerBean(context,"sftpConfig", SFTPConfiguration.class)

By calling registerBean method only the constructor is invoked , but @Import, @Autowire, @Value annotations are not invoked.

Comment From: wilkinsona

Spring Boot isn't involved at this level. All of the functionality you are asking about is part of Spring Framework. If you decide to raise this with the Spring Framework team, please take the time to refine your example of the problem to ensure that it compiles.