idea使用spring boot 热更新、热加载

修改代码后无需重新make、build、run项目,直接看到结果

两种方式

第一种:适合Idea自动装载的Run或Debug

1、Settings->Build project automatically

2、Ctrl+Shift+A ->搜索registry,找到Registry...,注意是后面有三个点的那个,然后找到compiler.automake.allow.when.app.running,勾选





第二种:这种方式不支持idea自动装载的run和debug,

Spring boot 提供了devtools,添加依赖,同时在settings里设置Build project automatically

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <fork>true</fork>
            </configuration>
        </plugin>
    </plugins>
</build>

配置好后使用命令启动 mvn spring-boot:run


推荐使用第一种方法


猜你喜欢

转载自blog.csdn.net/wshl1234567/article/details/78486138