maven-dependency-plugin之copy-dependencies

该目标功能:将依赖的 jar 包下载到指定的文件夹中。并不一起打包到最终包中。
项目参考《Maven-modules》,portal模块的pom.xml:


<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>earthartifactId>
        <groupId>ymqx.comgroupId>
        <version>1.0-SNAPSHOTversion>
    parent>
    <modelVersion>4.0.0modelVersion>

    <artifactId>portalartifactId>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}groupId>
            <artifactId>serviceartifactId>
            <version>${project.version}version>
        dependency>
    dependencies>

    <build>
        <plugins>
            
            

            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-dependency-pluginartifactId>
                <version>3.0.1version>
                <executions>
                    <execution>
                        <id>copy-dependenciesid>
                        <phase>packagephase>
                        <goals>
                            <goal>copy-dependenciesgoal>
                        goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/liboutputDirectory>
                            <overWriteReleases>falseoverWriteReleases>
                            <overWriteSnapshots>falseoverWriteSnapshots>
                            <overWriteIfNewer>trueoverWriteIfNewer>
                        configuration>
                    execution>
                executions>
            plugin>
        plugins>
    build>
project>

执行打包后:
maven-dependency-plugin之copy-dependencies_第1张图片
portal模块生成目录target下增加一个文件夹lib,lib包含所有依赖:
maven-dependency-plugin之copy-dependencies_第2张图片
一共33个依赖包,和repackage生成earth-1.0-SNAPSHOT.jar\BOOT-INF\lib一样。
maven-dependency-plugin之copy-dependencies_第3张图片

注:portal-1.0-SNAPSHOT.jar 没有依赖包:
maven-dependency-plugin之copy-dependencies_第4张图片

你可能感兴趣的:(Maven,maven)