使用Maven插件maven-dependency-plugin拷贝所有依赖的jar和pom文件

使用maven管理java项目的时候,有时候需要将依赖的第三方jar包一起打包发布,这就用到了maven-dependency-plugin插件,全称

org.apache.maven.plugins:maven-dependency-plugin:2.10:copy-dependencies

在pom文件中增加该插件的声明,如下所示:

<build>

    <plugins>

      <plugin>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-dependency-plugin</artifactId>

        <version>2.10</version>

        <executions>

          <execution>

            <id>copy-dependencies</id>

            <phase>package</phase>

            <goals>

              <goal>copy-dependencies</goal>

            </goals>

            <configuration>              <outputDirectory>${project.build.directory}/dependencies</outputDirectory>

              <overWriteReleases>false</overWriteReleases>

              <overWriteSnapshots>false</overWriteSnapshots>

              <overWriteIfNewer>true</overWriteIfNewer>

              <copyPom>true</copyPom>

            </configuration>

          </execution>

        </executions>

      </plugin>

    </plugins>

  </build>

执行Mvn package之后就可以将依赖的jar拷贝到dependencies目录,并且会将jar的pom一并拷贝下载。



本文出自 “学海无涯” 博客,请务必保留此出处http://snmpuser.blog.51cto.com/1027125/1757480

文章来自:http://snmpuser.blog.51cto.com/1027125/1757480
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3