本地jar包在maven工程中pom引用


背景

  在使用Maven的过程中,经常碰到有些jar包在中央仓库没有的情况。如果公司有私服,那么就把jar包安装到私服上。如果没有私服,那就把jar包安装到本地Maven仓库。下面是如何把jar包导入本地maven仓库。


解决方法

1、确定包信息

groupId:设置项目代码的包名(一般用公司或组织名)
artifactId:设置项目名或模块名 
version:版本号
packaging:什么类型的文件(jar包)
filePath:指定jar文件路径与文件名(同目录只需文件名)

2、在工程根目录下执行如下maven命令:

mvn install:install-file -DgroupId=<groupId> -DartifactId=<artifactId> -Dversion=<version> -Dpackaging=jar -Dfile=<filePath>

3、在pom的包依赖中引入刚才

<dependency>  
  <!--if add it into the </dependencyManagement>, it does not work-->  
  <groupId>[groupId]</groupId>  
  <artifactId>[artifactId]</artifactId>  
  <version>[version]</version>  
  <systemPath>[filePath]</systemPath>
  <scope>system</scope>
</dependency>

注意:maven命令在window系统下,不能使用powershell,否则会包xxx not exits。


转载于:https://www.cnblogs.com/aric2016/p/11508742.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值