重新加载静态内容的Spring Boot应用程序 [英] Reload static content spring boot application

查看:69
本文介绍了重新加载静态内容的Spring Boot应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Netbeans,并且正在使用Spring Boot开发我的第一个Web应用程序.我将HTML,js,CSS保留在"webapp"文件夹中,然后重构了项目,并将所有静态内容放入了/resources/static中.从那时起,我每次都必须重建项目,因为不会重新加载静态内容.

I am using Netbeans and I am developing my first web application using spring boot. I was keeping my HTML, js, CSS in "webapp" folder and then I refactored my project and I put all static content in /resources/static. Since then, I have to rebuild my project every time because the static content isn't reloaded.

如果我将浏览器同步插件用于Gulp,是否可以轻松绕过此问题?

Can I easily bypass this problem if I'll use browser-sync plugin for Gulp?

推荐答案

将以下内容添加到src/main/resources/application.properties:

Add the following to src/main/resources/application.properties:

spring.resources.static-locations[0]=file:src/main/resources/static/
spring.resources.static-locations[1]=classpath:/static/

文件:"会导致在刷新浏览器时重新加载内容, 查看相关问题.

The "file:" causes the content to be reloaded on refreshing the browser, see related issue.

或者,文件资源位置可以是在运行时发现以编程方式添加.

另请参见教程 a>.

这篇关于重新加载静态内容的Spring Boot应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆