Spring Boot 入门之热部署【2】

1.热部署

    当我们修改文件和创建文件时,都需要重新启动项目。这样频繁的操作很浪费时间,配置热部署可以让项目自动加载变化的文件,省去的手动操作。

在 pom.xml 文件中添加如下配置:

<!-- 热部署 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
    <scope>true</scope>
</dependency>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <!-- 没有该配置,devtools 不生效 -->
                <fork>true</fork>
            </configuration>
        </plugin>
    </plugins>
</build>

如图在 pom.xml配置:


注意:如果配置好之后无效,下面需要修改idea中的两个配置:

  • setting –> compiler  将 Build project automatically 勾选上。如图所示

  • 快捷键ctrl + shift + alt + /,弹出框,选择Registry。

  • 勾上 Compiler autoMake allow when app running


  • 重启项目可实现热部署功能。

猜你喜欢

转载自blog.csdn.net/qq_41307443/article/details/80726716