美文网首页
在idea中spring boot热部署不生效

在idea中spring boot热部署不生效

作者: wallany | 来源:发表于2019-06-01 22:35 被阅读0次
在IDEA中如何使用spring的热部署

1、添加maven依赖

      <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
            <scope>true</scope>
        </dependency>

2、插件配置

        <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <!-- 没有该配置,devtools 不生效 -->
                    <fork>true</fork>
                    <addResources>true</addResources>
                </configuration>
            </plugin>

但是在实际使用中发现即便这样配置之后,还是没有作用,这是为什么呢?
这是因为idea默认是没有自动编译的,我们这里需要添加修改配置.打开设置

1、File-Settings-Compiler-Build Project automatically


image.png

2、ctrl + shift + A 然后输入Registry


image.png

然后勾上 Compiler autoMake allow when app running


image.png
然后就可以开心的撸代码了

相关文章

网友评论

      本文标题:在idea中spring boot热部署不生效

      本文链接:https://www.haomeiwen.com/subject/xnpfxctx.html