在spring-boot-maven-plugin
中添加addResources
配置项:
org.springframework.boot spring-boot-maven-plugin true
使用mvn spring-boot:run
启动项目,而不是使用main()
方法,这样修改静态资源后便即时生效(和spring-boot-devtools
没半毛钱关系),下面是官方解释。
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.