Maven资源插件:如何将资源复制到目标文件夹并保留时间戳? [英] Maven Resources Plugin: how to copy resources to target folder and keep time stamps?

查看:62
本文介绍了Maven资源插件:如何将资源复制到目标文件夹并保留时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行清理&在项目的基础上,Maven将所有资源复制到目标文件夹,但是带有创建的时间戳,而不是src/main/resources文件夹中原始文件的时间戳.是否可以通过某种方式指示它保留原始时间戳?

When i execute a clean & build on a project, Maven copies all resources to the target folder but with the time stamp of the creation, not with the time stamps of the original files in the src/main/resources folder. Is it possible to somehow instruct it to keep the original time stamps?

这对我们造成问题的原因是,我们正在开发的软件在启动时具有数据库迁移功能,我们希望保持其在开发人员机器上的执行力.但是由于时间戳不断变化,这会导致不必要的资源重新加载到数据库中.

The cause why this is problematic for us is that the software we are developing has a database migration in startup time and we like to keep it executing on developer machines. But because of the ever changing time stamps this introduce unnecessary resource reloads to the database.

推荐答案

我认为使用您是否可以更改运行时从中加载文件的路径(可能是通过使其在每个环境中均可配置)?如果是这样,那么也许您可以将 ant与maven一起使用 并使用 ant的复制任务 具有 preservelastmodified 属性.

Can you change the path where the files are loaded from at runtime (probably by making it configurable per environment)? If so, then perhaps you can use ant with maven and use ant's copy task which has a preservelastmodified property.

目的是Maven的资源处理将继续照常工作,但是文件还将在每个版本中都复制到运行时使用的单独位置.

The intent being that Maven's resources handling would continue to work as usual, but the files would also be copied every build to a separate location used by the runtime.

这篇关于Maven资源插件:如何将资源复制到目标文件夹并保留时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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