转载

IDEA2021 热部署


背景

springboot开发,经常提到修改代码无需手动重启的配置。其中有一条就是ctrl+alt+shift+/,选择1 Registry,然后勾选设置compiler.automake.allow.when.app.running。

可 这个选项在2021版本的IDEA里找不到。

解决办法

2021版本这个选项的配置,改到设置-高级设置模块了。

ctrl+alt+s,进入设置,然后选择高级设置,在Compiler下勾选 Allow auto-make to restart even if developed application is currently running。 大功告成。enjoy。若解决了您的问题,别忘点个赞。

其他有关配置

编译设置

ctrl+alt+s,进入 设置 ==> Build,Execution,Deployment ==> Compiler,勾选 Build project automatically。

模块的pom文件中添加依赖和build配置

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork>  <!--dev-tools相关-->
                    <skip>true</skip>   <!--否则模块打包时候会提示 unable to find main class-->
                    <addResources>true</addResources>
                </configuration>
            </plugin>
        </plugins>
    </build>

允许运行中程序自动编译

也就是前文提到的Allow auto-make to restart even if developed application is currently running。

之前版本里,设置是通过 ctrl+alt+/,在弹出的界面选择 1 Registry,进行之后找到对应选项。

2021版本里,是通过crl+alt+s,在Advanced Settings里设置。

重启

若没生效,重启应用,重启IDEA再看看。

IDEA
  • 作者:Lider(联系作者)
  • 发表时间:2023-11-30 16:21
  • 版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)
  • 公众号转载:请在文末添加作者公众号二维码
  • 评论