現在大家大部分都通過Maven等工具來管理包,但是特殊情況下還是需要將包下載到本地。我們可以通過maven命令來完成這個需求。創建一個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> <dependency> <!-- jsoup HTML parser library @ http://jsoup.org/ --> <groupId>org.jsoup</groupId> <artifactId>jsoup</artifactId> <version>1.9.2</version> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.13</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-dependency-plugin</artifactId> <configuration> <excludeTransitive>false</excludeTransitive> <stripVersion>true</stripVersion> <outputDirectory>./lib</outputDirectory> </configuration> </plugin> </plugins> </build> </project>
然后在當前目錄按住Shift鍵,同時點擊右鍵,選擇“在此處打開命令窗口”。然后在命令窗口內輸入命令:
mvn dependency:copy-dependencies
回車運行后,就可以在當前目錄下面發現一個lib文件夾,這個文件夾內,就是我們需要的jar包。如下圖所示:
原文地址:
通過Maven將指定Jar包下載到指定的本地目錄