SpringBoot如何通过devtools实现热部署

2026-01-12 12:44:08 作者:用户投稿

这篇文章主要介绍了SpringBoot如何通过devtools实现热部署,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

在项目的pom.xml文件添加如下两段

<dependency> 
    <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-devtools</artifactId>
      <version>1.5.7.RELEASE</version>
      <optional>true</optional> 
</dependency> 

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

如果使用的是Intellij IEDA开发工具,还需要到设置里将project automatically勾选上;File->Setting->Build,…->Compiler 将右侧project automatically勾上

Intellij IEDA 使用ctrl+shift+a 快捷键搜索Registry,选择搜索出来的第一个

找到compiler.automake.allow.when.app.running,勾上开启此功能即可

此时重新启动项目即可实现热部署,改动任意代码会立即生效,不用再每次重新启动项目

猜你喜欢

联络方式:

400 9058 355

邮箱:8955556@qq.com

Q Q:8955556

微信二维码
在线咨询 拨打电话

电话

400 9058 355

微信二维码

微信二维码