zoukankan      html  css  js  c++  java
  • 本地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。


  • 相关阅读:
    设计模式—适配器模式
    设计模式—策略模式 状态模式
    设计模式——装饰模式和代理模式
    C++常考算法
    ModelState.AddModelError使用
    Json
    ref与out
    三层与mvc
    新的方法(Set<T>)实现mvc的crud
    【程序45】
  • 原文地址:https://www.cnblogs.com/aric2016/p/11508742.html
Copyright © 2011-2022 走看看