Maven-添加jar包到本地/远程仓库

当在配置的中央仓库找不到我们需要的jar包时,我们如何使用Maven去引用这个jar包

1,下载所需要使用的jar包,我这里用ojdbc14.jar来做这个实验

2,使用mvn命令将jar包添加到本地仓库中去

mvn install:install-file -Dfile=ojdbc14.jar -DgroupId=ojdbc -DartifactId=ojdbc -Dversion=1.0.0 -Dpackaging=jar

我的jar保存放在D:/ojdbc14.jar,所以我在命令行中先切换目录到D:,再执行此命令

GroupID是项目组织唯一的标识符

ArtifactID是项目的唯一的标识符,实际对应项目的名称,就是项目根目录的名称。

version是项目的唯一的版本号


3.在项目中引用


这样我们就实现了将jar添加到本地仓库并引用的目的


添加到远程仓库:mvn deploy:deploy-file -DgroupId=com.tima.javax.jta -DartifactId=jta -Dversion=1.0.0 -Dpackaging=jar -Dfile=jta.jar -Durl=http://192.168.131.8:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty


  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
执行mvn clean install出现[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building springboot-schema 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading: http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-maven-plugin/2.2.2.RELEASE/spring-boot-maven-plugin-2.2.2.RELEASE.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.419 s [INFO] Finished at: 2023-07-22T19:52:51+08:00 [INFO] Final Memory: 9M/245M [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.springframew ork.boot:spring-boot-maven-plugin:jar:2.2.2.RELEASE: Could not transfer artifact org.springframework.boot:spring-boot-maven-plugin:pom:2.2.2.RELEASE from/to central (http://repo.maven. apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-maven-plugin/2.2.2.RELEASE/spring-boot-maven-plugin-2.2.2.RELEASE. pom. Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException PS C:\Users\16283\Desktop\springbootc8hzm>
07-23

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值