idea熱部署SpringBoot

1)在pom文件中添加依賴:

<dependencies>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <!--該配置必須-->
                <fork>true</fork>
            </configuration>
        </plugin>
    </plugins>
</build>

2)左上角依次找到【File】——【Settings...】——【Build,Execution,Deployment】——【Compiler】,

勾選"Build project automatically",然後右下角【Apply】——【OK】:

3)點擊idea右上角搜索圖標,搜索"Registry",選擇搜索出來的最後一個:

 

4)找到"compiler.automake.allow.when.app.running",勾選,

點擊【Close】關閉:

5)重啓idea

【說明】爲什麼在 idea 中啓用自動編譯依然沒有熱部署?

idea監測到項目runninng 或者 debuging 會停用自動編譯,所以還需要手動biild [Ctrl + F9] 或者 [ctrl + b]

 

補充:上述方式maven打包可能會出錯,推薦使用 Jrebel 配置熱啓動。

見:idea配置Jrebel

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章