gpt4 book ai didi

maven - 在 Maven 中如何从生成的 jar 中排除资源?

转载 作者:行者123 更新时间:2023-12-03 05:48:48 25 4
gpt4 key购买 nike

当我创建具有依赖项的可执行 jar 时(使用 this guide ),所有属性文件也打包到该 jar 中。如何阻止它发生?谢谢。

更新:我尝试使用 Maven resources plugin 排除它们,但是当我在 Eclipse 中运行应用程序时,我的应用程序将找不到属性文件(右键单击模块 -> 运行方式 -> Java 应用程序)

更新:感谢您提供有用的答案。我想我最好花时间学习Maven,目前我只选择最简单的解决方案。

最佳答案

要从 jar/目标目录中排除任何文件,您可以使用 <excludes> pom.xml 文件中的标记。

在下一个示例中,所有带有 .properties 的文件不包括扩展名:

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.properties</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
</build>

关于maven - 在 Maven 中如何从生成的 jar 中排除资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4113697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com