在 Maven 中使用过滤器时,如果属性不存在,如何停止构建

发布于 2024-10-07 07:18:19 字数 251 浏览 0 评论 0原文

我目前正在使用 Maven Filter 来配置 XML 文件。问题是,即使您编写了过滤器文件中不存在的错误属性,构建也不会失败或发出任何警告。 我认为这是非常危险的。如果我的一位同事在 XML 文件中添加了一个属性,却忘记告诉我们。构建后(没有任何警告或错误),XML 文件中的属性将保留为 ${XX.XX.XX}。这肯定会导致系统运行时出现问题。

如果 Maven 发现某个属性与过滤器文件中的任何内容都不匹配,是否有办法停止构建?

I'm currently using Maven Filter to configure XML files. The problem is the building won't failed or give any warns even you wrote an error property which doesn't exists in the filter file.
I think it's very dangerous. If one of my colleagues added a property in the XML file and forget to tell us. After building (without any warning or errors), the property in the XML file will be left like ${XX.XX.XX}. That'll surely cause problems when running the system.

Is there a way to stop the build if Maven finds a property doesn't match anything in the filter file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

|煩躁 2024-10-14 07:18:19

我认为 maven-enforcer-plugin 应该能够解决你的问题。
http://maven.apache.org/plugins/maven-enforcer-plugin/

I think maven-enforcer-plugin should be able to solve your problem.
http://maven.apache.org/plugins/maven-enforcer-plugin/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文