<span>本地jar包在maven工程中pom引用</span>


背景

  在使用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。


全部评论

相关推荐

投递中移(苏州)软件技术有限公司等公司6个岗位 > 牛客解忧铺
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务