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>
 
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM