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

时间:2019-09-11 22:13:23   收藏:0   阅读:446

背景

??在使用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
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!