Maven资源插件:如何将资源复制到目标文件夹并保留时间戳?

编程入门 行业动态 更新时间:2024-10-26 10:28:51
本文介绍了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.

推荐答案

我认为使用 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资源插件:如何将资源复制到目标文件夹并保留时间戳?

本文发布于:2023-07-15 10:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1110616.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:资源   如何将   文件夹   插件   目标

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!