官方資料http://maven.apache.org/plugins/maven-dependency-plugin/
當項目很大時,若是將全部的依賴都打包到war包或jar包中,會致使這個文件很大,而不少狀況下,依賴的庫是不須要改變的。解決方法是將依賴的庫放在單獨的目錄中,在執行java命令時,將它們加入到classpath。
插件的用法示例以下html
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <excludeScope>provided</excludeScope><!--若是<includeScope>與<excludeScope>同時出現,<excludeScope>將被忽略--> <outputDirectory>${project.basedir}/target/lib</outputDirectory> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>false</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> </configuration> </execution> </executions> </plugin>
須要注意的是,若是<includeScope>與<excludeScope>同時出現,<excludeScope>將被忽略
這個插件中的scope的含義與dependency中的scope含義是有差異的,好比<includeScope>compile</includeScope>是指包含compile、provided、system。 具體介紹看官方文檔https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.htmljava