An open API service indexing awesome lists of open source software.

https://github.com/baratharivazhagan/spring-programmatically-register-beans


https://github.com/baratharivazhagan/spring-programmatically-register-beans

spring spring-boot

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

          

# spring-programmatically-register-beans

Spring boot application demonstrates how to use Configurable Application context to register beans programmatically.

### How to register a bean programmatically in spring application context ?

```
ConfigurableApplicationContext applicationContext=SpringApplication.run(Application.class, args);
ConfigurableBeanFactory beanFactory=applicationContext.getBeanFactory();
beanFactory.registerSingleton("testBean", new Object());
```