During development, when finished we need to run a functional application testing, there may be little more than a small function bug
, we need to be corrected to restart the server, this invisible slow down the speed of development has increased development time, SpringBoot
providing up spring-boot-devtools
, and enable us to change the application configuration file, restart the application automatically!
Open the pom.xml
file to add dependencies
<dependency>
<groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
As long as the
classpath
files are changed, it will automatically restart. This is useful when using the IDE, because it can quickly change the code feedback. By default,classpath
any point to Folder entity will be monitored, pay attention to modify some resources such as static assets, view templates without restarting the application.
SinceDevTools
monitoringclasspath
resources under, so the only way to trigger restart is updatedclasspath
. In theEclipse
inside, save a modified file will cause theclasspath
update, and trigger the restart. InIntelliJ IDEA
, the default is not automatically compiled, we need to set the automatic compilation.
IDEA is set to automatically compile:
(1). Shortcut keys Ctrl+Alt+S
to open the settings, Build, Execotion, Deployment-> Compiler-> Build Project automatically checked items
(2). Shortcuts Ctrl + Shift + Alt + /
, choose Registry
(3).勾选 Compiler autoMake allow when app running
Restart the application, when changes to the code, watch the console output, you will find Spring Boot has detected a change in the file, and restart, you will find the experience so why stick, very cool!
Author: Le silly ass
link: https: //www.jianshu.com/p/0f62cab718ef
Source: Jane book
Jane book copyright reserved by the authors, are reproduced in any form, please contact the author to obtain authorization and indicate the source.