关于idea spring boot 热部署配置未生效问题

906 阅读1分钟

首先pom中必须配置 devtools

       <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>
                    <addResources>true</addResources>
                </configuration>
            </plugin>
        </plugins>
    </build>

这一点必须配置

                <configuration>
                    <!-- 没有该配置,devtools 不生效 -->
                    <fork>true</fork>
                    <addResources>true</addResources>
                </configuration>

若以上两处配置后还未生效。

  • setting –> compiler ,将 Build project automatically 勾选上
    
  • alt + shift + a (我的是ctrl+alt+shfit+/)搜索 registry (第一个),弹出框后下拉找到compiler.automake.allow.when.app.running 勾选上即可。
    

这两步必须都做,并不是两种方法。注意:这是一种方法的两步骤。 勾选后应该是点击close按钮。 如果还未生效,可以尝试换下工作。