Java 如何在 IDEA Intellij 上使用 Spring-boot 进行自动重新加载
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33349456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to make auto reload with Spring-boot on IDEA Intellij
提问by u1559249
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. It wastes lots time!
我写了一个基于 Spring-boot,tomcat,freemarker 的项目,运行成功,但是每当我修改一些模板和 java 类时,我必须重新启动服务器或使用 Intellij 上的“重新加载更改的类”菜单使更改生效. 浪费很多时间!
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 位
回答by wang.chun
CTRL+F9
to make project with debugging.
The idea is to make the project automatically work while not running or debugging!
CTRL+F9
使项目与调试。这个想法是让项目在不运行或调试时自动工作!
Setting->Build->Compiler->check Make project automatically.
设置->构建->编译器->勾选自动生成项目。
回答by Hocine Ben
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 automaticallyis selected.
其次,验证选项复选框File->Setting –> Build, Execution, Deployment –> Compiler–>
自动生成项目被选中。
Last, press SHIFT+CTRL+A
for Linux/Windows users or Command+SHIFT+A
for Mac users, then type registryin the opened pop-up window. Scroll down to Registry...
using the down arrow key and hit ENTER
on Registry...
. In the Registry
window verify the option compiler.automake.allow.when.app.runningis checked.
最后,SHIFT+CTRL+A
对于 Linux/Windows 用户或Command+SHIFT+A
Mac 用户,按,然后在打开的弹出窗口中键入registry。向下滚动到Registry...
使用向下箭头键和命中ENTER
上Registry...
。在Registry
窗口中验证选项compiler.automake.allow.when.app.running被选中。
The instructions above are taken from here
以上说明取自here