What is the meaning of lazy-initialization in Spring Boot properties file ?
In one of our projects in company. A teammate did this long time ago, and I don't get why ?
The property documentation says :
Whether initialization should be performed lazily. - default value is false
7 Replies
⌛
This post has been reserved for your question.
Hey @FirasRG! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
IIRC that should be about bean initialization
so if you have
then lazy initialization allows Spring to create and register
SomeComponent
before the OtherComponent
bean is fully initialized
nvm not that
it means that if you declare a bean, it will only be created when it's actually neededso that property makes all beans in the app lazy ?
yes
got it
and that could harm the app ?
:Huh:
it can delay errors
so if there's something wrong with a bean, the application might still start but cause exceptions in the future
with eager initialization, you see these exceptions directly when the applicatio starts up so you immediately know when something is wrong
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.