maven项目添加libs下的jar

一.怎么在pom.xml中添加项目中libs下的jar呢,而不是从本地仓库中添加?

方式一:

1、首先将要添加的jar包复制到项目中的libs文件夹下

2.然后在pom.xml中添加如下代码:例如 htmlunit-2.21-OSGi.jar

<dependency>
  <groupId>htmlunit</groupId>
  <artifactId>htmlunit</artifactId>
  <version>2.21-OSGi</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/libs/htmlunit-2.21-OSGi.jar</systemPath>
</dependency>

 注意:上面的方法,试了一下,发现不行,不知道,为何,谁要是试了没有问题,可以分享一下,使用的下面的方式,没有问题

方式二:

1.通过命令将jar安装到本地仓库

 例如:invenoUtil-1.1.jar

mvn install:install-file -DgroupId=com.inveno -DartifactId=invenoUtil -Dversion=1.1 -Dpackaging=jar -Dfile=C:\GitHub\mr_parent\parent\libs\invenoUtil-1.1.jar

例如:distribute-1.0.jar
mvn install:install-file  -DgroupId=com.inveno  -DartifactId=distribute-Dversion=1.0  -Dpackaging=jar  -Dfile=C:\GitHub\mr_parent\parent\libs\distribute-1.0.jar

2.在pom.xml中配置
<dependency>
            <groupId>com.inveno</groupId>
            <artifactId>invenoUtil</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>com.inveno</groupId>
            <artifactId>distribute</artifactId>
            <version>1.0</version>
        </dependency>

posted @ 2019-05-19 02:04  望少  阅读(1537)  评论(0编辑  收藏  举报