Java / Micronaut Interview questions
What are the types of bean scopes in Micronaut?
Micronaut ships several built-in scopes that control how many instances of a bean exist and how long they live.
| Scope | Lifecycle |
@Singleton | One shared instance for the whole application context. |
@Prototype | A new instance every time the bean is injected or looked up (the default when no scope is declared). |
@RequestScope | One instance per HTTP request. |
@Context | Eagerly created and initialized when the ApplicationContext starts, rather than lazily. |
@Refreshable | Recreated when configuration changes and a refresh event is published. |
@ThreadLocal | One instance per thread. |
Custom scopes can also be created by implementing Micronaut's CustomScope interface for specialized lifecycles.
More Related questions...