• 本地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。


  • 相关阅读:
    同一WpfApplication下简单的页面转换
    触发器
    程序包
    函数
    存储过程
    游标
    我的第一个SolidWorks图
    张量系列(tensor02)
    张量系列-Tensor(01)
    Python与矩阵论——特征值与特征向量
  • 原文地址:https://www.cnblogs.com/aric2016/p/11508742.html
Copyright © 2020-2023  润新知