Skip to content

7. Springboot热部署(IDEA)

7.1. 添加devtools的依赖

xml
<!--devtools-->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-devtools</artifactId>
</dependency>

7.2. 在maven-plugin上添加configration

 <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork>
                </configuration>
            </plugin>
        </plugins>
    </build>

7.3. 修改idea的配置,自动编译

File-Settings-Build,Execution...--Compiler

img

7.4. 修改idea允许在程序运行过程中编译

  • idea低于2021-一下的版本

快捷键键

CTRL+SHIFT+ALT+/

img

img

  • 高于2021+ 选择的路径:
  • File--> settings--Allow auto -make to start even if .......

7.5. 测试热部署

程序启动过程中,修改方法。当修改代码后idea失去焦点之后会触发springboot的重启

Released under the MIT License.