Hot Deployment of Spring Boot

Hot Deployment of Spring Boot

 

Since a Spring Boot application is usually an ordinary Java Application, if we modify the source code during development and do not want to close and restart, Spring Boot also provides us with a tool to complete the hot deployment function of the application, we only need to introduce spring The -boot-devtools module can complete the hot deployment effect of the application.

 

<dependency>
       <groupId>org.springframework.boot</groupId>   
       <artifactId>spring-boot-devtools</artifactId>        
       <optional>true</optional>
</dependency>

 

Using spring-boot-devtools will monitor the changes of resources under ClassPath. Once most resource files change, it will trigger the automatic restart function, but for resource files in special directories, these directories are /META- INF/maven, /META-INF/resources ,/resources,/static,/public , /templates ( note: these directory files are located in the classpath ), spring-boot-devtools will not trigger restarting the application, but it will trigger Reload of these resource files.

 



 

If the a.txt file in the static directory is modified, the automatic restart function will not be triggered. Users can customize the directory that does not trigger the restart through the spring.devtools.restart.exclude property. When adding the following to application.properties:

 

spring.devtools.restart.exclude=public/**

 

At this point, modifying files in the static directory will automatically trigger a restart, but modifying files in the public directory will still not trigger a restart. If you want to keep the default directories, but also want to add some directories without triggering restart, you can specify them through spring.devtools.restart.additional-exclude .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326475943&siteId=291194637