SpringBoot学习之路:12.Spring Boot使用idea开发如何配置热加载

          java开发的ide用最多的无非就是eclipse和idea,在eclipse中开发springboot,要使项目热加载资源只须要在pom文件中引入springboot的开发工devtools便可。可是该工具在使用idea开发springboot时单纯的引入并不起做用,还须要一些代码支持和idea设置才能生效。下面咱们就在idea中使用maven构建的springboot项目进行热部署配置。java

1.使用maven构建一个springboot项目

2.引入springboot开发工具包

打开项目中的pom.xml文件,加入如下依赖:spring

<!--开发工具依赖-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
</dependency>

注意:也能够在构建的时候勾选上devtools工具包springboot

3.配置参数是devtools生效

单纯的引入上面的devtools工具包是不起做用的,咱们还须要在maven编译插件处配置一个参数:app

<build>
    <!--编译插件配置-->
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <!--没有该项配置,devtools不会起做用-->
                <fork>true</fork></configuration>
        </plugin>
    </plugins>
</build>

4.设置idea的自动编译项目

打开idea的设置,找到编译,勾选自动编译项(File—>Settings—>Bulid—>Compiler )eclipse

5.在idea中注册maven自动编译项

首先使用快捷键ctrl + Shift + Alt + / 打开Maintenance插件注册界面maven

而后点击注册进入idea的插件注册界面ide

最后找到compiler.automake.allow.when.app.running这一项勾选,使maven的自动编译插件注册到idea中。spring-boot

亲测有效!工具

个人idea版本:开发工具

相关文章
相关标签/搜索