springboot开启热部署(修改java代码自动重新部署项目)

springboot

pom.xml添加依赖:

        <!--   热部署工具     -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>


application.yml配置文件中添加:(可以不写)

spring:
#热部署生效
devtools:
restart:
enabled: true
#设置重启的目录
#additional-paths: src/main/java
#classpath目录下的WEB-INF文件夹内容修改不重启
exclude: WEB-INF/**


设置WEB-INF下的jsp修改不需要重启。
当我们修改了java类后,IDEA默认是不自动编译的,而spring-boot-devtools又是监测classpath下的文件发生变化才会重启应用,所以需要设置IDEA的自动编译:

(1)File-Settings-Compiler-Build Project automatically


(2)ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running

 

 

posted @ 2021-08-26 20:42  低调的。。。  阅读(326)  评论(0编辑  收藏  举报