从maven中央仓库下载jar包

1、安装本地jar包到maven本地仓库

mvn install:install-file:主要是将本地自定义jar安装到maven仓库,然后在pom中可以直接通过dependency的方式来引用。

-DgroupId=自定义groupId 设置groupId 名
-DartifactId=自定义artifactId 设置该包artifactId名
-Dversion=自定义版本1.0.0 设置版本号
-Dpackaging=jar 设置该包的类型,有如下值:pom、jar、war、maven-plugin
-Dfile=文件路径 设置该jar包文件所在的路径与文件名
完整的命令如下:

mvn install:install-file -DgroupId=com.xxx -DartifactId=maven-test -Dversion=1.0.0 -Dpackaging=jar -Dfile=C:\lib\test.jar

注意一定要写绝对地址,我写了相对地址去执行,就不停的刷屏

2、命令行方式从maven中央仓库下载jar到本地仓库

浏览器登录maven中央仓库网址
【maven中央仓库网址】https://mvnrepository.com/

先看下图,找到你要下载的
在这里插入图片描述

图中红色框的就是你的参数,补全下面的命令行

mvn dependency:get -DremoteRepositories=https://mvnrepository.com/artifact/io.github.XXX/你的jar包名 -DgroupId=io.github.XXX -DartifactId=你的jar包名 -Dversion=版本号

参数内容
-DremoteRepositories红框中第一行的网址
-DgroupId红框中groupId
-DartifactId红框中artifactId
-Dversion红框中version

补全后,打开dos窗口,输入上面命令。
如果没有在你的项目根目录下输入上面命令,十之八九会报错,如下

No plugin found for prefix ‘dependency’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo]

在这里插入图片描述
原因是maven不识别这个命令dependency,需要在你项目根目录下的pox.xml文件里写上

<plugin>
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <version>3.0.2</version> 
    <executions> 
      <execution> 
        <id>copy-dependencies</id> 
        <phase>package</phase> 
        <goals> 
          <goal>copy-dependencies</goal> 
        </goals>
      </execution> 
    </executions> 
</plugin> 

参考链接点击这里

然后进入项目根目录,再执行你的mvn dependency:get 命令那一大串,就可以下载成功了。如下
在这里插入图片描述

3、idea刷新下载

idea开发工具还是很好的,这里就更简单了,刷它。点击下面的红色框。
在这里插入图片描述
然后点击开看看里面的dependencies,找到你要下的包。就好了。

  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值