Spring Boot Hot Deployment

Source: Internet
Author: User

In the actual development of Spring Boot hot deployment, modifying a page data or logical function requires a restart of the app. This virtually reduces the development efficiency, so it is necessary to use thermal deployment. What is a hot deployment? After the application starts, it will load the compiled class file into the virtual machine, under normal circumstances when the project modifies the source file, it needs to be completely recompiled and reloaded (need to restart the app). The hot deployment is to listen to changes in the class file, only the modified class reload, without the need to restart the application, making development easier. Spring Boot configuration enables hot deployment The first way: the Maven plugin-springloaded adds springloaded dependencies in the Spring-boot-maven-plugin plug-in configuration.
<Build><Plugins><Plugin><Groupid>org.springframework.boot</Groupid><Artifactid>spring-boot-maven-plugin</Artifactid><Dependencies><dependency> < groupid>org.springframework</ groupid> <artifactid>springloaded </artifactid> < version>1.2.5.release</version > </dependency> </dependencies> </plugin> </plugins></ BUILD>             
by command: MVN Spring-boot:run launches the app, modifies the controller's code or modifies the HTML page (remember to pressctrl+shirt+f9Reload the modified class file, and then refresh the page, you will find that the display results change. Note: The first way to launch the app is valid for MVN spring-boot:run this way, but not for running the Application.java startup app directly.

Note 1: If you find that there is no hot deployment effect, you need to check if automatic compilation is turned on in the idea configuration:

Open Preferences > Compiler, tick Build project automatically

NOTE 2: If you use the Thymeleaf template engine, you need to set the template default cache to False

Add in Application.properties:
#禁止thymeleaf缓存(建议:开发环境设置为false,生成环境设置为true)spring.thymeleaf.cache=false
The second way: rely on the Spring-boot-devtools Thermal deployment module Pom.xml Add dependencies:
<!-- 热部署模块 --><dependency>    <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <!-- 这个需要为 true 热部署才有效 --></dependency>
Restart the app, modify the controller's code or modify the HTML page and then refresh the page, and you will find that the display results change.

Spring Boot Hot Deployment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.