如何在IDEA Intellij上使用Spring-boot进行自动重新加载

集成显*_*成显卡 30 java junit spring intellij-idea spring-boot

我已经写了一个基于Spring-boot,tomcat,freemarker的项目,我成功运行它,但每当我修改一些模板和java类时,我必须重新启动服务器或使用Intellij上的"reload changed classes"菜单使更改生效.这浪费了很多时间!

然后我尝试使用springloaded作为官方说:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>springloaded</artifactId>
            <version>1.2.0.RELEASE</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/springloaded-1.2.0.RELEASE.jar</systemPath>
        </dependency>
    </dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud)

然后我重新运行服务器,但没有按预期工作!在模板或类上进行任何更改后,我仍然需要重新启动服务器.

如何配置springloaded以自动重新加载.非常感谢!


Spring-boot的版本是1.3.0RC1

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.0.RC1</version>
</parent>
Run Code Online (Sandbox Code Playgroud)

maven版本:3.2 jdk:1.8 intellij:14.1.5 os:windows 8.1 64位

Par*_*tho 121

注意:: 对于那些在注册表中找不到该选项的人。对于我的情况,较新版本的intellij idea @Version:2021.2 将compiler.automake.allow.when.app.running 选项移至高级设置:

在此输入图像描述


Hoc*_*Ben 55

首先,请确保您添加spring-boot-devtools为依赖项:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>
Run Code Online (Sandbox Code Playgroud)

其次,验证是否已选中File->Setting –> Build, Execution, Deployment –> Compiler–>自动选项复选框Build项目.

最后,按下SHIFT+CTRL+ALinux/Windows用户或Command+SHIFT+AMac用户,然后在打开的弹出窗口中键入registry.向下滚动到Registry...使用向下箭头键和命中ENTERRegistry....在Registry窗口中,验证选项compiler.automake.allow.when.app.running是否已选中.

以上说明摘自此处

  • 感谢它的工作,您是否知道在使用命令行运行它时是否可行? (2认同)
  • 请注意,这已移至高级设置:https://youtrack.jetbrains.com/issue/IDEA-274903/In-IntelliJ-2021.2-compiler.automake.allow.when.app.running-disappear.-Unable-to -enable-live-reload-under-Spring-boot#focus=Comments-27-5089338.0-0 (2认同)

bit*_*xyz 15

对于 macOS

  1. 首选项 -> 编译器 -> 在构建时自动检查 BUild 项目 asds

  2. shift + 命令 + A 在此处输入图片说明

在此处输入图片说明

查看 compiler.automake.allow.when.app.running

如果未重新加载静态文件,请按CTRL+F9强制重新加载。


小智 9

CTRL+F9制作带有调试的项目。这个想法是让项目在不运行或调试的情况下自动工作!

设置->构建->编译器->勾选自动生成项目。


小智 5

也许您可以检查构建是否因构建工具 设置的任何更改而触发 在此输入图像描述