配置SpringBoot项目热部署

我们在开发中反复修改类、页面等资源,每次修改后都是需要重新启动才生效,这样每次启动都很麻烦,浪费了大量的时间,我们可以在修改代码后不重启就能生效,在 pom.xml 中添加如下配置就可以实现这样的功能,我们称之为 热部署

  1. 在 pom.xml 文件中增加依赖配置
<!--热部署配置-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
</dependency>
<!--SpringBoot项目打包时,会将内置的Tomcat一起打包-->
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

  1. 开启 Intellij IEDA 自动编译
    在这里插入图片描述
  2. Shift+Ctrl+Alt+/,选择Registry, 设置app运行期间支持自动编译部署
    在这里插入图片描述
  3. 以后其他的springboot项目如果希望热部署,只需要引入spring-boot-devtools即可

感谢阅读, 如有什么更好的建议或方法 ,可以留言或进群交流:1101584918,欢迎大家加入。

猜你喜欢

转载自blog.csdn.net/Lance_welcome/article/details/106506007