我的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/