重命名Maven War构建上的静态文件 [英] Rename static files on maven war build

查看:97
本文介绍了重命名Maven War构建上的静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出一种方法,可以同时重命名我在Web项目中拥有的静态文件,所有这些文件都可以同时进行.

I am trying to figure out a way by which I could rename the static files I have in my web project, all of them at the same time.

我真正需要的是能够过滤我所有的静态文件名以添加版本号或类似名称,只是为了避免它们被浏览器缓存.

Exactly what I need is to be able of filtering all my statics filenames to add a version number or something similar just to avoid them from being cached by browsers.

类似于将custom.css转换为custom-1.23.css的情况,其中1.23是给定过滤器的值.

Something like converting custom.css into custom-1.23.css where 1.23 would be the value of a given filter.

此行为看起来与资源插件对文件内容的处理非常相似,但是我找不到与文件名相同的方法.

This behaviour looks really similar to what resources plugin does with the content of the files, but I couldn't find a way of doing the same with the filenames.

有人知道类似的东西吗?

Does anyone knows something similar?

非常感谢

推荐答案

您可以更改服务对象的目录,而不是文件名,例如

You could change the directory they are served from rather than the file name e.g.

/static/$ {version}/custom.css

/static/${version}/custom.css

资源插件可让您在战争中更改目标目录.

The resources plugin would let you change the target directory in the war.

这篇关于重命名Maven War构建上的静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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