Configure @Startup to avoid multiple calls in dev mode. #44591
lordofthejars
started this conversation in
Community
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I developed an example that populates some data in MongoDB at startup. The problem is that if I am running in dev mode when I make a change, the dev service is not restarted, but the startup method is called again, so it inserts data again.
I know there are a lot of workarounds there (in my case, I always delete and then insert), and it is fine, but if the startup logic was super big and taking a lot of time to execute, then again, I could create some kind of conditional or whatever, but it requires some code.
Since we own the
@Startup
annotation, I mean it is not a Jakarta annotation, I don't know if it would be possible (I see some implementation difficulties), but would it be possible to add a property that the developers set meaning that only the first time the startup method is called but the rest of the time it is not called anymore. By default, this would be false of course, but we let the user to decide this.Beta Was this translation helpful? Give feedback.
All reactions