springboot项目在idea实现热部署

在使用Idea 开发SpringBoot项目的过程中,为了避免因为修改文件而产生频繁的手动重启操作,使用 spring 提供的 spring-boot-devtools 开启热部署。步骤如下:

1、在 pom 文件中引入相关 jar 包。

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-devtools</artifactId>
	<scope>runtime</scope>
	<optional>true</optional>
</dependency>

2、添加编译插件

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

3、在 idea 中开启自动编译

  • 点击 File -> setting -> Build,Execution,Deployment -> Compiler,把 Build project automatically 勾上。如下图:

4、开启热注册

  • 快捷键 ctrl+shift+alt+/,选择 Registry ,然后勾选 compiler.automak.allow.when.app.running 和 actionSystem.assertFocusAccessFromEdt ,如下图:

5、重启 idea 之后便可以愉快的玩耍啦...

原文地址:https://www.cnblogs.com/Mhang/p/12525333.html