1、建一個pom.xml文件
<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>com.companny.maven</groupId> <artifactId>hello</artifactId> <version>0.0.1-SNAPSHOT</version> <!-- 添加依賴 --> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> </project>
2、在該pom.xml所在目錄:
cmd下:輸入以下命令:
mvn dependency:copy-dependencies
3、下載完成后的jar在dependency的目錄下
4、將下載的jar包加入倉庫:
下載的jar路徑 參數2 參數3 版本
mvn install:install-file -Dfile="c:\javaee\hello\target\dependency\junit-4.12.jar" -DgroupId=junit -DartifactId=junit -Dversion=4.12 -Dpackaging=jar