IDEA 编写 SpringBoot 项目自动编译刷新

需求背景

IDEA 编写传统 web 应用使用外置的 Tomcat 时,前端代码修改后是可以自动编译,页面刷新就能看到效果的。而现在开发 SpringBoot 项目时,因为它使用的是内置的 Tomcat ,所以即使是在 html 页面上修改内容,它也必须重新启动之后才能看到效果,这样开发上很不方便。本文将解决这个问题。

解决步骤

修改 pom.xml 文件

1)在 pom.xml 文件 中添加热部署:

		
        
            org.springframework.boot
            spring-boot-devtools
            true
            true
        

2)在 pom.xml 文件 中添加插件:


            
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    
                    true
                
            

设置 IDEA

设置 IDEA 的自动编译:File—> Settings—>Build…-> Compiler 勾选 Build Project automatically,IDEA 新版本中是 Build project automatically
IDEA 编写 SpringBoot 项目自动编译刷新_第1张图片

测试运行

添加、设置完成之后,修改页面之后,按 Ctrl+F9 即可实时编译,浏览器刷新即可看到效果。

来源:https://blog.csdn.net/wangmx1993328/article/details/84648773

你可能感兴趣的:(springboot,自动编译)