How to add local jar into your local maven repository

本文介绍了一种当无法从Maven中央仓库找到所需jar包时的解决方案:从官方网站下载jar包,并通过特定命令将其手动安装到本地Maven仓库中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

As subject, sometimes, we can not find some jars in Maven centre repository, so we should add them into our local repository.

Steps:

  • Download jar from offical web site.

  for example, I download mysql jdbc driver from oracle, and put the jar into my disk, path: D:\apache-maven-3.3.3\mavenRepository\mysql\mysql-connector-java\5.1.36-bin 

  • Install the jar 

execute following commend:

run cmd

cd: d:

cd: D:\apache-maven-3.3.3\mavenRepository\mysql\mysql-connector-java\5.1.36-bin

mvn install:install-file -Dfile=mysql-connector-java-5.1.36-bin.jar -DgroupId=mysql -DartifactId=mysql-connector-java -Dversion=5.1.36-bin -Dpackaging=jar.


Here you will run into an error, say there is no project, missing a pom, if your commend is:

mvn install:install-file -Dfile=D:\apache-maven-3.3.3\mavenRepository\mysql\mysql-connector-java\5.1.36-bin\mysql-connector-java-5.1.36-bin.jar -DgroupId=mysql -DartifactId=mysql-connector-java -Dversion=5.1.36-bin -Dpackaging=jar.

error screen is 



only difference is -Dfile should not contains full path, if you want to install the jar, enter into the fold where your jar is in.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值