Current location - Health Preservation Learning Network - Slimming men and women - SpringBoot series: springdevtools module
SpringBoot series: springdevtools module
Spring-boot-devtools is a toolkit provided by Spring Boot for developers, which can improve the working efficiency of developers. We can introduce the toolkit in the following ways:

expert

Gradler

Some libraries supported by SpringBoot use caching technology to improve performance. For example, the template engine will cache the compiled template to avoid parsing the template file every time; Spring MVC will also cache the Http header properties of some static files.

Although caching can greatly improve the performance of the program in production environment, it is not very friendly in the development stage, so spring-boot-devtools will disable these caches by default. For example, spring-boot-devtools will disable the caching of thyme through the property Sping. Thyme leaves. Caching.

When we use IDE (such as Eclipse, IDEA, etc. ) To develop a SpringBoot project, spring-boot-devtools will automatically restart the project when it detects a change in the project classpath.

Of course, spring-boot-devtools has optimized this. It creates two class loaders, one is the base class loader used to load the classes of the dependent third-party libraries, and the classes being developed in the project will be loaded by another restart class loader, so that every time the project restarts, a new restart class loader is actually created to load the class files generated in the project, so it will be much faster than the general project startup.

Spring-boot-devtools supports global setting function. By default, the following configuration files are located in the directory $HOME/. Config/spring-boot will be automatically loaded and applied to all SpringBoot projects running on this machine ($HOME stands for the home directory of the current user):

If you want to turn on the remote debugging function of the SpringBoot project, you need to package spring-boot-devtools together when the application is packaged (by default, spring-boot-devtools are not packaged together, it is only an auxiliary package during development), such as Maven project, and we can set it as follows:

When starting a local application, you need to select the main class as org.springframework.boot.devtools.remotespringapplication, and set the program parameter as http://ip:port (address of remote service).

Spring-boot-devtools is based on shutdown hook, so it cannot be set to false (Spring application. SetRegisterShutdownHook (false))。

https://docs . spring . io/spring-boot/docs/current/reference/html single/# using . dev tools