http://maven.apache.org/components/plugins/maven-dependency-plugin/plugin-info.htmlhtml
典型場景:apache
1.須要某個特殊的 jar包,可是有不能直接經過maven依賴獲取,或者說在其餘環境的maven倉庫內不存在,那麼如何將咱們所須要的jar包打入咱們的生產jar包中。maven
2.某個jar包內部包含的文件是咱們所須要的,或者是咱們但願將它提取出來放入指定的位置 ,那麼除了複製粘貼,如何經過maven插件實現呢?測試
dependency插件咱們最經常使用到的是ui
dependency:copy url
dependency:copy-dependencies:Goal that copies the project dependencies from the repository to a defined location. spa
dependency:unpack .net
dependency:unpack-dependencies 這四個插件
若是要實現上述的兩種場景,咱們須要的 是 第一個和第三個。code
copy
樣例:將兩個指定的jar包junit slf4j-log4j12 分別輸出到${project.build.directory}/lib/lib1 目錄下 即${project.basedir}/target/lib 目錄下。
copy-dependencies
<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}/deploydependencis</outputDirectory> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>false</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> <includeScope>compile</includeScope> <includeScope>runtime</includeScope> </configuration> </execution> </executions> </plugin>
測試樣例:
執行MVN打包命令: