idea配置springboot热部署

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

idea配置springboot热部署

haiqiang0225   2022-05-28 我要评论

2022版本配置SpringBoot热部署

网上搜到的以前版本的都是更改Registry...,勾选compiler.automake.allow.when.app.running,然后新版的IDEA的Registry...里没有这个选项,最后找到了解决方案,亲测有效,链接如下:

ref: In IntelliJ 2021.2 compiler.automake.allow.when.app.running disappear. Unable to enable live reload under Spring boot

1.IDEA版本

在这里插入图片描述

2. 添加依赖

  • 如果只有一个项目,直接在pom.xml里添加下面所有的即可
  • 父项目pom.xml<project>标签内添加:
<build>
       <plugins>
           <plugin>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-maven-plugin</artifactId>
               <version>2.6.4</version>
               <executions>
                   <execution>
                       <goals>
                           <goal>repackage</goal>
                       </goals>
                   </execution>
               </executions>
               <configuration>
                   <fork>true</fork>
                   <addResources>true</addResources>
               </configuration>
           </plugin>
       </plugins>
   </build>

子项目pom.xml<dependencie>标签内添加,注意要在父项目xml里定义版本:

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

3.更改IDEA设置

preferences... -> Compiler

在这里插入图片描述

preferences... -> Advanced Settings -> Allow auto-make to start even if developed application is currently running

在这里插入图片描述

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们