我需要在最终的JAR中包含自定义文件(/com/app/log4.properties)。
使用jar-with-dependencies时如何向JAR添加一个文件?
现在该JAR中只有类文件。我正在使用:
mvn assembly:assembly
我的pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.app.Start</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
谢谢。
答案 0 :(得分:5)
在src/main/resources
中放置需要在最终工件中的非Java文件,在这种情况下:
src/main/resources/com/app/log4j.properties