Cla*_*ela 1 spring static spring-boot gulp browser-sync
我正在使用Netbeans,我正在使用spring boot开发我的第一个Web应用程序.我将我的htmls,js,css保存在"webapp"文件夹中,然后我重构了我的项目,并将所有静态内容放在/ resources/static中.从那时起,我每次都必须重建我的项目,因为静态内容没有重新加载.
如果我将为Gulp使用浏览器同步插件,我可以轻松绕过这个问题吗?
将以下内容添加到src/main/resources/application.properties:
spring.resources.static-locations[0]=file:src/main/resources/static/
spring.resources.static-locations[1]=classpath:/static/
Run Code Online (Sandbox Code Playgroud)
"file:"导致在刷新浏览器时重新加载内容, 请参阅相关问题.
通常静态内容会被 spring-boot 插件复制到构建目录(如果使用 maven 则为 target)。您可以在 {build-directory}/classes/static 中找到您的文件:这些是您应该修改以反映更改的文件。您还应该将更改复制到 resources/static 中,因为每当您重新启动 Spring Boot 时,都会复制这些文件。