IntelliJ IDEA spring boot 热重载手动保存? [英] IntelliJ IDEA spring boot hot reload on manual save?

查看:92
本文介绍了IntelliJ IDEA spring boot 热重载手动保存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是:

  1. 在 IntelliJ IDEA 中为 Spring Boot 项目禁用自动保存

  2. 手动保存文件时总是热重载项目

在我看来,同时实现这两个目标是不可能的.

我可以通过修改这些设置在 IntelliJ IDEA 中禁用自动保存:

构建、执行、部署 -> 编译器 取消勾选自动构建项目

我也认为需要修改这些选项:

外观&行为 -> 系统设置 取消选中同步下的两个保存文件(帧停用和自动保存文件)

我可以在 Mkyong 的帮助下启用热重载:

3.在 IntelliJ 中启用 compiler.automake.allow.when.app.running 注册表设置.您可以使用快捷方式 Shift+Command+A 在 IntelliJ 中访问注册表,然后搜索注册表.

<小时>

当您手动保存更改时,第 3 步将自动构建您的项目(制作项目).

==========================================================================一旦通过您的 IDE 手动保存更改,这些步骤将强制 spring 服务器重新启动.但是,即使服务器重新启动,每次进行更改时也需要刷新浏览器.要强制您的浏览器也自动刷新,您需要在浏览器中安装一个名为 Live Reload 的扩展程序.检查此链接 http://livereload.com/extensions/.该链接将向您展示如何安装此扩展程序,具体取决于您的浏览器.

My goal is:

  1. Disable autosave in IntelliJ IDEA for a spring boot project

  2. Hot reload the project always when files are manually saved

Seems to me that it is impossible to achieve these two goals simultaneously.

I can disable autosave in IntelliJ IDEA by modifying these settings:

Build, Execution, Deployment -> Compiler Uncheck Build project automatically

Also I think what is too needed is modify these options:

Appearance & Behaviour -> System Settings Uncheck both save files under Synchronization (frame deactivation and save files automatically)

I can enable hot reload by the help of Mkyong: Mkyong-help As you can see from the link, it requires setting 'Build project automatically' on. If I do both of these steps, then the application will always save on edit, and it will always hot reload the app.

This is so frustrating, I thought IntelliJ IDEA was a good modern IDE, with these kind of industrial core features like hot reloading handled easy?

The problem is, that I really don't want to hot reload my application on every change I make to the files! Because then it will be continuously hot reloading, which will break the application most of the time. Just so unnecessary and wasting resources. I want to hot reload always when I manually save a file, which is a standard for so many other editors. There has to be a solution for this problem, because people want reasonable hot reload for their development.

解决方案

As far as I understand, your issue is that you want the spring server to reload automatically whenever you make changes and then manually save them. Right? if the that is the case, follow my steps and hopefully you will get what desire.

1. include the spring-boot-devtools dependency

Maven

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

Gradle

dependencies {
    compile("org.springframework.boot:spring-boot-devtools")
}

2. enable "Make project automatically" in the compiler preferences for automatic restarts to work.

3. enable the compiler.automake.allow.when.app.running registry setting in IntelliJ. You can access the registry in IntelliJ using the shortcut Shift+Command+A, then searching for registry.


The 3rd step will make building your project (make project) automatic when you save you changes manually.

======================================================================== These steps will enforce spring server to reboot once changes has been saved manually via your IDE. However, you need to refresh your browser every time you make a change even though the server is rebooted. To enforce your browser to refresh automatically as well, you need an extension installed in your browser called Live Reload. Check this link http://livereload.com/extensions/. the link will show you how to install this extension depends on your browser.

这篇关于IntelliJ IDEA spring boot 热重载手动保存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆