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。


  • 相关阅读:
    MSSQL
    Dapper
    Asynchronous Programming
    PHP on CentOS (LAMP) and wordpress
    CSS
    TypeScript & JavaScript
    AngularJS 2.0
    ReadMe.md MarkDown file
    shortcuts on Windows and MacOS
    移动平台的meta标签
  • 原文地址:https://www.cnblogs.com/aric2016/p/11508742.html
Copyright © 2011-2022 走看看