在spring-boot-maven-plugin中添加addResources配置項(xiàng):
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<addResources>true</addResources>
</configuration>
</plugin>
使用mvn spring-boot:run啟動(dòng)項(xiàng)目,而不是使用main()方法,這樣修改靜態(tài)資源后便即時(shí)生效(和spring-boot-devtools沒半毛錢關(guān)系),下面是官方解釋。
When addResources is enabled, any src/main/resources folder will be added to the application classpath when you run the application and any duplicate found in target/classes will be removed. This allows hot refreshing of resources which can be very useful when developing web applications. For example, you can work on HTML, CSS or JavaScript files and see your changes immediately without recompiling your application. It is also a helpful way of allowing your front end developers to work without needing to download and install a Java IDE.