开发中,每次对类的修改,都需要重启服务,很浪费时间,影响效率。下面介绍一种springboot热部署的方法
在pom文件中引入devtools依赖:
    <!-- 配置Spring Boot热部署依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>这里多了一个optional选项,是为了防止将devtools依赖传递到其他模块中。当开发者将应用打包运行后,devtools会被自动禁用。
同时需要在spring-boot-maven-plugin插件中进行如下的配置:
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!-- 实现热部署的设置 -->
                <configuration>
                    <fork>true</fork>
                </configuration>
            </plugin>
        </plugins>设置IDEA的配置
自动构建项目

在高级选项中勾选

 
                            