我想在构建时将项目内的资源复制到 jar 中的特定文件夹中。
我在我的 pom.xml
中使用此代码:
<resource>
<directory>${basedir}/locale</directory>
</resource>
将 locale 目录中的所有文件复制到我的 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/