1
我需要在最终的JAR中包含自定义文件(/com/app/log4.properties)。如何在JAR中使用Maven程序集插件jar -with-dependencies包含自定义文件
如何在使用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>
谢谢。
什么,如果该文件位于文件系统中的某个地方? – Enerccio 2016-06-08 11:51:34
@Enerccio如果?然后,您将您的log4j设置为使用外部配置文件。 – 2016-06-08 14:20:38
我试图从jdk透明地包括一个罐子,没有大惊小怪 – Enerccio 2016-06-08 15:07:37