-->

如何包括与Maven组装JAR文件定制插件JAR-与依赖性(How to include custo

2019-10-17 20:54发布

我需要在最后的JAR自定义文件(/com/app/log4.properties)。

我怎样才能使用的jar-具有依赖性,当一个文件添加到我的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>

谢谢。

Answer 1:

把那只需要在最终神器非Java文件src/main/resources ,在这种情况下:

src/main/resources/com/app/log4j.properties


文章来源: How to include custom files in JAR with Maven assembly plugin jar-with-dependencies