Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

The default deployment mode of JSP page in SpringBoot is production mode deployment, so when we modify the JSP page, we have to restart to see the result of the modification, which is very unfriendly to our JSP page development, so we can enable the hot deployment of SpringBoot, This allows us to immediately see the results of our JSP modifications without restarting the SpringBoot application.

To enable hot deployment, simply add a configuration to the.yml file:

server:
  jsp-servlet:
    init-parameters:
      development: true # JSP hot deployment
Copy the code

But this only opens up the hot deployment of JSP, which allows changes to the page to be displayed in real time, but cannot be refreshed in real time when we modify other code, such as the control layer, service layer, and persistence layer. In order to see the changes, we still need to restart the application, which is contrary to our original intention, so in order to modify the non-page code can be refreshed in real time, can be deployed in real time, we need to enable global hot deployment.

Start by introducing Maven dependencies in your project:

<! -- Hot deployment -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>
Copy the code

This is a hot deployment tool provided by SpringBoot. Import it and then enable automatic compilation of IDEA:

To allow IDEA to swap class files while the program is running, press Ctrl + Alt + Shift + / :

Then select Registy… In the window that pops up, select this item:

This allows global hot deployment to be configured so that applications can be written without frequent reboots.