gpt4 book ai didi

java - Maven - 将资源复制到 jar 中的特定位置

转载 作者:行者123 更新时间:2023-11-29 04:59:35 25 4
gpt4 key购买 nike

我想在构建时将项目中的资源复制到我的 jar 中的特定文件夹中。我在我的 pom.xml 中使用这段代码:

<resource>
<directory>${basedir}/locale</directory>
</resource>

将语言环境目录中的所有文件复制到我的 jar 中。但是文件都被复制到 jar 文件的根目录下,而不是在 locale 文件夹中。

是否可以使用 Maven 将资源复制到导出的 jar 文件中的特定位置?

最佳答案

您需要使用 targetPath属性。引用 Maven 引用:

targetPath: Specifies the directory structure to place the set of resources from a build. Target path defaults to the base directory. A commonly specified target path for resources that will be packaged in a JAR is META-INF.

<resource>
<directory>${basedir}/locale</directory>
<targetPath>locale</targetPath>
</resource>

关于java - Maven - 将资源复制到 jar 中的特定位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32543027/

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