SpringBoot笔记(三)IDEA实现devtools热部署

找了好几个文章,都是给个pom配置就完事了,根本不行,最后连查带试,算是弄出来了

设置pom.xml

dependencies

<!--springBoot工程实现热部署-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>

build->plugins

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <!--这里是新加的-->
    <configuration>
        <fork>true</fork>
    </configuration>
</plugin>

设置配置文件

application.properties或application.yml中禁用缓存

以下仅供参考,没有的就去掉,需要的就加上

spring.thymeleaf.cache=false
spring.freemarker.cache=false
spring.groovy.template.cache=false
spring.velocity.cache=false

开启IDEA自动编译

打开setting进行设置,然后确定
1

打开Maintenance选项卡选择Registry…

快捷键:

eclipse模式 Ctrl+Shift+Alt+/

IDEA模式 CTRL + SHIFT + A

2

勾选compiler.automake.allow.when.app.running

3

好了,可以用了

还有一种情况是read artifactId failed,那么这说明没下载到资源,可以手动把jar包放到库里,也可以加上version版本号让ide去加载。

猜你喜欢

转载自blog.csdn.net/lftaoyuan/article/details/80065600