[英]How to update static resources in Spring MVC without rebuilding?
I have a classic Spring MVC project where my resource files are put in the directory: 我有一个经典的Spring MVC项目,其中我的资源文件放在目录中:
webapp -- resources -- js webapp-资源-js
webapp -- resources -- css webapp-资源-CSS
I also use: 我还使用:
<!--declare resources-->
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />
My question what do I need to config so that every time I update the css & js files the changes appear when I refresh the page ? 我的问题是我需要配置什么,以便每次更新css和js文件时,所做的更改都在刷新页面时出现?
Right now I have to rebuild the project each time a change is made so that the war file is updated. 现在,每次进行更改时,我都必须重建项目,以便更新war文件。
One solution would be to split your project in two: - a front-end module - a classic war module 一种解决方案是将您的项目分成两部分:-前端模块-经典战争模块
This way, you can set up whatever front-end build tool you want to (grunt, gulp, etc) and ship all your optimized in a web JAR as a dependency of your war module. 这样,您可以设置任何想要的前端构建工具(咕unt声,吞咽声等),并将所有优化的优化工具作为war模块的依赖项交付到Web JAR中。
And of course, this way you can serve resources directly from disk, no need to redeploy your server each time. 当然,通过这种方式,您可以直接从磁盘提供资源,而无需每次都重新部署服务器。 There's a full example here .
这里有一个完整的例子 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.