maven 從pom.xml 下載jar包到本地
阿新 • • 發佈:2018-11-11
時至今日,maven已經是每個開發人員必備的工具了。而有些情況我們需要把jar下載到本地使用。
下面就說一下怎麼通過pom下載jar包到本地。
直接上乾貨。
第一步:建立一個pom.xml檔案
<?xml version="1.0" encoding="UTF-8"?> <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"> <modelVersion>4.0.0</modelVersion> <groupId>Spider</groupId> <artifactId>Spider</artifactId> <version>1.0</version> <dependencies> <!-- https://mvnrepository.com/artifact/junit/junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> </project>
第二步:建立update.bat檔案
mvn dependency:copy-dependencies
直接雙擊執行,即可下載pom中引用的jar到當前目錄的taget目錄下。
附記:配置下載目錄
<plugin> <artifactId>maven-dependency-plugin</artifactId> <configuration> <excludeTransitive>false</excludeTransitive> <stripVersion>true</stripVersion> <outputDirectory>./lib</outputDirectory> </configuration> </plugin>
附件:打包下載
參考博文:https://www.cnblogs.com/cliyun/p/5765875.html