Spring-boot-devtools is a good thing, can be deployed at any time during the development of debugging, without the need to manually start and stop each time. The first two days a project check log, found that there are always such error log output:
Org.springframework.boot.devtools.restart.silentexitexceptionhandler$silentexitexception At Org.springframework.boot.devtools.restart.SilentExitExceptionHandler.exitCurrentThread ( SILENTEXITEXCEPTIONHANDLER.JAVA:90) At Org.springframework.boot.devtools.restart.Restarter.immediateRestart (restarter.java:184) At Org.springframework.boot.devtools.restart.Restarter.initialize (restarter.java:163) At Org.springframework.boot.devtools.restart.Restarter.initialize (restarter.java:552) At Org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartingEvent ( RESTARTAPPLICATIONLISTENER.JAVA:67) At Org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent ( RESTARTAPPLICATIONLISTENER.JAVA:45) At Org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener ( simpleapplicationeventmulticaster.java:167) At Org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent ( simpleapplicationeventmulticaster.java:139) At Org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent ( simpleapplicationeventmulticaster.java:122) At Org.springframework.boot.context.event.EventPublishingRunListener.starting (Eventpublishingrunlistener.java : 68) At Org.springframework.boot.SpringApplicationRunListeners.starting (springapplicationrunlisteners.java:48) At Org.springframework.boot.SpringApplication.run (springapplication.java:303) At Org.test.Application.main (application.java:15) |
Look at the main structure of the project, roughly like this, I made a simplification:
The first is the boot entry for spring boot:
package org.test;import org.springframework.boot.springapplication;import org.springframework.boot.banner.mode;import org.springframework.boot.autoconfigure.springbootapplication; @SpringBootApplicationpublic class application { public static void main (String[] args) { try { springapplication app = new springapplication (Application.class); app.setbannermode (Mode.off); app.setwebenvironment (False); app.run (args); } catch (Exception ex) { &Nbsp; ex.printstacktrace (); } }}
The main service is roughly the same (simplified):
Package Org.test;import Javax.annotation.postconstruct;import org.springframework.stereotype.service;@ Servicepublic class Mainservice {@PostConstruct public void StartServer () {System.out.println ("START"); }}
The above error is reported as soon as it is started, but in fact it does not affect any functionality, and the Devtools thermal deployment feature is still in effect. Compared to the previous project, we found that the problem is on the main () method, Springapplication.run () one but put in the Try...catch block will cause Devtools to throw an exception. Remove the Try...catch in main (), or move the App.run (args) out of the try...catch, or catch to the exception do not Printstacktrace (), then run there will be no error log.
Specific reasons, such as free to go back to the source bar, for spring boot, Try...catch is really superfluous.
This article is from the "Rabbit Nest" blog, please be sure to keep this source http://boytnt.blog.51cto.com/966121/1919063
Use spring boot devtools do not superfluous add Try...catch