Home > Java > javaTutorial > Graphical tutorial on how SpringBoot implements hot deployment in IntelliJ IDEA

Graphical tutorial on how SpringBoot implements hot deployment in IntelliJ IDEA

不言
Release: 2019-02-16 11:43:25
forward
2445 people have browsed it

This article brings you a graphic tutorial on how to implement hot deployment of SpringBoot in IntelliJ IDEA. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

During the actual development process, the code is often modified to restart the application. Each manual restart is troublesome and has low development efficiency, so hot deployment is very necessary for development. This article will introduce how to restart the application in IntelliJ IDEA (version 2018.2 .5) Implement hot deployment of SpringBoot project.

This article uses spring-boot-devtools to implement hot deployment. Just follow the following two steps to complete it.

1. Modify pom.xml

spring-boot-devtools is a module that serves developers, the most important function of which is hot deployment. The principle is to restart the application after discovering changes in the code, but it is faster than manually stopping and restarting. The underlying principle is to use two ClassLoaders. One ClassLoader loads classes that will not change (third-party Jar packages), and the other ClassLoader loads classes that will change, called restart ClassLoader. In this way, when there are code changes, the original The restart ClassLoader is discarded and a restart ClassLoader is re-created. Since there are fewer classes to be loaded, a faster restart time is achieved. That is, devtools will monitor file changes under the classpath and will immediately restart the application (occurring at the time of saving)

After configuring spring-boot-devtools, the specific pom.xml file content is as follows:

org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
<!-- 引入热部署jar包 -->
org.springframework.boot
spring-boot-devtools
<!-- optional=true,依赖不会传递,该项目依赖devtools;之后依赖该项目的项目如果想要使用devtools,需要重新引入 -->
true
<!-- 引入热部署依赖插件 -->
org.springframework.boot
spring-boot-maven-plugin
<!-- IntelliJ IDEA本地测试去掉fork也生效 -->
true
Copy after login

2 . Turn on idea automatic compilation and automake function

(1). Settings --> Compile --> Build project automatically --> Check


idea settings automatic compilation screenshot

(2). CTRL SHIFT ALT / --> Find Registry --> Find and check compiler.automake.allow.when.app.running


idea settings compile.automake screenshot

After completing the above two steps, you can implement hot start in IntelliJ IDEA.

Warm reminder: After turning on the idea automatic compilation and automake functions, you must restart IntelliJ IDEA

The above is the detailed content of Graphical tutorial on how SpringBoot implements hot deployment in IntelliJ IDEA. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template