简体   繁体   English

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

[英]how to make auto reload with Spring-boot on IDEA Intellij

I had wrote a project base on Spring-boot,tomcat,freemarker, I run it successful, but whenever I modify some templates and java class, I must restart server or use "reload changed classes" menu on Intellij to make the changes become effective.我写了一个基于 Spring-boot,tomcat,freemarker 的项目,运行成功,但是每当我修改一些模板和 java 类时,我必须重新启动服务器或使用 Intellij 上的“重新加载更改的类”菜单使更改生效. It wastes lots time!浪费很多时间!

Then I try to use springloaded as the official said :然后我尝试使用 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>

then I rerun server, but doesn't work as expected!然后我重新运行服务器,但没有按预期工作! I still need to restart server after any change on template or class.在对模板或类进行任何更改后,我仍然需要重新启动服务器。

How could I configure the springloaded to auto reload.我如何配置弹簧加载以自动重新加载。 Thanks a lot!非常感谢!


The version of Spring-boot is 1.3.0RC1 Spring-boot 的版本是 1.3.0RC1

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.0.RC1</version>
</parent>

maven version:3.2 jdk:1.8 intellij :14.1.5 os:windows 8.1 64 bit Maven 版本:3.2 jdk:1.8 智能:14.1.5 操作系统:windows 8.1 64 位

First, be sure that you added spring-boot-devtools as dependency:首先,确保您添加了spring-boot-devtools作为依赖项:

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

Second, verify that the option check-box File->Setting –> Build, Execution, Deployment –> Compiler–> Build project automatically is selected.其次,验证选项复选框File->Setting –> Build, Execution, Deployment –> Compiler–> Build project automatically被选中。

Last, press SHIFT+CTRL+A for Linux/Windows users or Command+SHIFT+A for Mac users, then type registry in the opened pop-up window.最后,Linux/Windows 用户按SHIFT+CTRL+A或 Mac 用户按Command+SHIFT+A ,然后在打开的弹出窗口中键入registry Scroll down to Registry... using the down arrow key and hit ENTER on Registry... .使用向下箭头键向下滚动到Registry...并在Registry...上按ENTER In the Registry window verify the option compiler.automake.allow.when.app.running is checked.Registry窗口中验证选项compiler.automake.allow.when.app.running被选中。

If the static files are not reloaded, press CTRL+F9 to force a reload.如果未重新加载静态文件,请按CTRL+F9强制重新加载。

The instructions above are taken from here以上说明取自here

For macOS对于 macOS

  1. Preference -> Compiler -> check BUild project on build automatically首选项 -> 编译器 -> 在构建时自动检查 BUild 项目asds

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

在此处输入图片说明

check compiler.automake.allow.when.app.running检查compiler.automake.allow.when.app.running

If the static files are not reloaded, press CTRL+F9 to force a reload.如果未重新加载静态文件,请按CTRL+F9强制重新加载。

CTRL+F9 to make project with debugging. CTRL+F9调试项目。 The idea is to make the project automatically work while not running or debugging!这个想法是让项目在不运行或调试时自动工作!

Setting->Build->Compiler->check Make project automatically.设置->构建->编译器->勾选自动生成项目。

Note::For who those not found that option in registry.The newer version of intellij idea for my case @Version:2021.2 the compiler.automake.allow.when.app.running option is moved to advanced settings:注意::对于那些在注册表中没有找到该选项的人。对于我的案例@Version:2021.2 的 Intellij 想法的较新版本,compiler.automake.allow.when.app.running 选项已移至高级设置:

在此处输入图片说明

Possibly you could check if build is fired on any changes on Build Tools settings可能您可以检查构建工具设置的任何更改是否触发构建在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM