spring provides a developer named for the
spring-boot-devtools
module to the Spring Boot application supports hot deployment and improve development efficiency of the developer, without having to manually restart the Spring Boot application.
devtools The principle: the use of two ClassLoader, ClassLoader one of the major load does not change the class (third-party jar package), another ClassLoader loaded with a change of class, it is also calledrestart ClassLoader
, due to the need to load a few classes, you can realization restart within a faster rate
Add devtools depend in pom file
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<!-- optional=true,依赖不会往下传递,
如果有项目依赖本项目,并且想要使用devtools,需要重新引入 -->
<optional>true</optional>
<scope>runtime</scope>
</dependency>
Explanation
Page hot deployment
Configuring spring.thymeleaf.cache in application.properties file = false (after the page changes will take effect immediately)
Some resources when changes need not necessarily trigger a restart
Thymeleaf template can be edited in-place. Change the default resource path includes: / META-INF / maven, / META-INF / resources, / resources, / static, / public or / templates does not trigger a restart, but will trigger real-time reload. If reverse exclude these paths may be used as follows: static spring.devtools.restart.exclude = / , public /