Reputation: 1414
Print Statement is getting executed twice which is present before run method invoke in Spring boot
After run method invoke, one more print statement is present which is getting executed once as expected.
It seems that control is hitting the main method twice but why not later one print statement is getting executed twice.
Note - I have dev-tools configure in pom.xml
Could someone help me to understand the flow behind that use case.
Thank you.
Upvotes: 1
Views: 423
Reputation: 1010
This behaviour is normal, if you have DevTools on your classpath. If you look at the Stack, you will see, that the second execution is under the hood of the RestartLauncher.
---------------- START ----------------
java.lang.Exception
at de.solitics.overwatch.app.OverwatchApplication.main(OverwatchApplication.java:37)
---------------- START ----------------
java.lang.Exception
at de.solitics.overwatch.app.OverwatchApplication.main(OverwatchApplication.java:37)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Upvotes: 2