我正在使用 Netbeans,并且正在使用 Spring Boot 开发我的第一个 Web 应用程序。我将 HTML、js、CSS 保存在“webapp”文件夹中,然后重构了我的项目,并将所有静态内容放入 /resources/static
中。从那时起,我每次都必须重建我的项目,因为静态内容没有重新加载。
如果我为 Gulp 使用浏览器同步插件,我可以轻松绕过这个问题吗?
最佳答案
将以下内容添加到 src/main/resources/application.properties:
spring.web.resources.static-locations[0]=file:src/main/resources/static/
spring.web.resources.static-locations[1]=classpath:/static/
“文件:”会导致刷新浏览器时重新加载内容, see related issue .
或者,文件 resource locations可以是discovered在运行时和added programmatically .
另请参阅documentation和 tutorial .
请注意,在 Spring Boot 2.4 之前,该属性称为“spring.resources.static-locations”。
关于spring - 重新加载静态内容 Spring Boot 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43693393/