当我执行清理&在项目的基础上,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.
推荐答案我认为使用 Maven资源插件.
您是否可以更改运行时从中加载文件的路径(可能是通过使其在每个环境中均可配置)?如果是这样,那么也许您可以将 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资源插件:如何将资源复制到目标文件夹并保留时间戳?
发布评论