如何将所有必需的jar放入最终jar内的lib文件夹中,而不提供maars?

时间:2016-12-23 18:43:58

标签: maven-3

我已阅读问题How do I put all required JAR files in a library folder inside the final JAR file with Maven?和答案

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-dependencies</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
                <overWriteReleases>false</overWriteReleases>
                <overWriteSnapshots>false</overWriteSnapshots>
                <overWriteIfNewer>true</overWriteIfNewer>
            </configuration>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <!-- <classpathPrefix>lib</classpathPrefix> -->
                <!-- <mainClass>test.org.Cliente</mainClass> -->
            </manifest>
            <manifestEntries>
                <Class-Path>lib/</Class-Path>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>

提供了对OP提出质疑的内容。

是否可以在不包含声明为提供的依赖项的情况下执行此操作?

1 个答案:

答案 0 :(得分:0)

<excludeScope>provided</excludeScope>

下添加<overWriteIfNewer>true</overWriteIfNewer>