spring-boot-devtools熱加載不起做用

在開發過程當中,但願修改時可以及時更新修改,即熱加載,可是spring-boot-devtools不起做用。這主要是兩個緣由致使。java

1、spring-boot-maven-plugin插件沒有配置 ,以下:web

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <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、運行方式是java -jar target/xxx.jar,這種方式是生產應用程序,這種也不會起做用,spring

能夠選擇maven插件提供的run執行程序:shell

mvn spring-boot:run

指定配置文件的方式:maven

mvn spring-boot:run -Dspring-boot.run.profiles=test

3、另外,IDEA是不會自動編譯的,能夠使用快捷鍵執行手動編譯:Ctrl+F9,若是是更新單個文件使用快捷鍵Ctrl+Shift+F9spring-boot

相關文章
相關標籤/搜索