使用maven下载jar包

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

posted @ 2021-12-19 15:20  CiscoLee  阅读(2493)  评论(0编辑  收藏  举报