【问题标题】:How to add a folder (and it's content) to the root of a Jar file with Maven in compile time?如何在编译时使用 Maven 将文件夹(及其内容)添加到 Jar 文件的根目录?
【发布时间】:2019-07-31 17:30:51
【问题描述】:

我需要将src/main/resources/example下的example文件夹的内容复制到maven生成的jar文件的根目录

问题似乎出在 spring-boot-maven-plugin 上,它在 jar 内的 BOOT-INF 文件夹下生成。

<resources>
    <resource>
        <targetPath>example</targetPath>                           
        <directory>${basedir}/src/main/resource/example</directory>
    </resource>
</resource>

我希望示例文件夹下的内容被编译到 jar 的根目录 实际的: Actual behavior

【问题讨论】:

标签: java maven


【解决方案1】:

请删除所有 spring-boot 插件,并仅使用评论中解释的资源标签。

<resources>
 <resource>
   <targetPath>Where_you want_loc</targetPath>
</resource></resources>

【讨论】:

    【解决方案2】:

    为什么不将文件夹复制到 JAR,而不是访问它所在的文件夹?

    Java: Acess and read all files in a folder

    希望对你有所帮助...

    【讨论】:

    • 由于 CI 原因,我需要在编译时添加 jar 内的内容
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-15
    • 1970-01-01
    • 2021-07-31
    相关资源
    最近更新 更多