Can spring boot implement the hot deployment of jar packages?

CSDN Q & A 2022-02-13 09:13:24 阅读数:222

spring boot implement hot deployment

springboot The project can achieve jar Hot deployment of packages , Every time you modify the front-end page in development, you have to re install, It's a waste of time .




Take the answer :

DevTools Implementation of hot deployment ( Self restart )
After activating the developer tool ,ClassPath Any changes to the file in will trigger the application to restart . In order to restart fast enough , Classes that will not be modified ( The third party JAR package ) All loaded into the base class loader , The application code will be loaded into a separate restart class loader . When a change is detected , Only class loading will be restarted Restart the device .
There are some ClassPath You do not need to restart the application after changing the resources in . image Thymeleaf Such a view template can be edited directly , Don't have to restart . stay /static or /public The static resources in do not need to restart the application , therefore Spring Boot When the developer tool is restarted, the following directories are excluded :/META-INF/resources、/resources、/static、/public、/templates.
One 、pom rely on

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <!-- optional The purpose is to inherit his project without inheriting this devtools plug-in unit --> </dependency> <build> <plugins> <plugin> <!-- Hot deployment configuration --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!--fork: If there is no such configuration , Whole devtools It won't work ( According to personal situation , Better add )--> <fork>true</fork> </configuration> </plugin> </plugins> </build>

Two 、 Check Build project automatically( An automated build )

img

3、 ... and 、IDEA Set to during program operation , Still allow automatic compilation
step : ctrl + shift + alt + /, choice Registry, Tick on Compiler autoMake allow when app running

img

img

Check the position of the target and find it by yourself , The order is different , Check it and remember to restart it !

Four 、 Set auto load resource configuration and compilation

img


copyright:author[CSDN Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130913224225.html