gpt4 book ai didi

java - 如何在构建过程中在 jar 外部创建 configs 目录

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:01:59 25 4
gpt4 key购买 nike

我的maven项目中有如下结构

src
|-main
|-java
|-org.my....
|- ..classes
|-resources
|-configs
|-config1.xml
|-config2.xml
|-log4j.xml

我想在构建项目后获取jar 外的resources/configs 目录。也就是说,在我运行 mvn clean install 之后,我想在 target

中看到以下结构
project.jar
configs
|-config1.xml
|-config2.xml

我正在使用 maven-shade-plugin 并尝试了以下方法,但没有成功。

    <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<manifestEntries>
<Main-Class>org.mainClass</Main-Class>
<Class-Path>configs</Class-Path>
<!--<resource>src/main/resources/configs</resource>-->
<!--<file>README.txt</file>-->
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>

最佳答案

请试试这个

https://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html

<outputDirectory>${basedir}/target/extra-resources</outputDirectory>

关于java - 如何在构建过程中在 jar 外部创建 configs 目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48985657/

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