maven項目從本地向本地倉庫導入jar包


方法一(推薦):

<dependency>
            <groupId>guagua-commons</groupId>
            <artifactId>guagua-commons</artifactId>
            <version>1.0.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/guagua-commons-1.0.1.jar</systemPath>
</dependency>

如上,將jar包guagua-commons-1.0.1.jar復制到項目根目錄(和src目錄同級)的lib文件夾下,加入<scope>system</scope>
<systemPath>${project.basedir}/lib/jar包名稱</systemPath>即可

方法二:
在maven安裝目錄下的bin目錄中進入cmd,運行:  mvn install:install-file -Dfile=jar包的路徑 -DgroupId=<groupId>中的內容 -DartifactId=<artifactId>標簽中的內容 -Dversion=<version>的內容 -Dpackaging=jar     出現BUILD SUCCESS即成功,即可在項目中正常導入jar包。
  弊端:當項目跟換服務器時,需要重新以同樣的操作將jar包導入到本地maven倉庫。
例子:mvn install:install-file -Dfile=F:\message\guagua-commons-1.0.1.jar  -DgroupId=guagua-commons   -DartifactId=guagua-commons  -Dversion=1.0.1   -Dpackaging=jar     出現BUILD SUCCESS即成功;

之后在項目中正常導入jar包即可:

<dependency>
            <groupId>guagua-commons</groupId>
            <artifactId>guagua-commons</artifactId>
            <version>1.0.1</version>
</dependency>


免責聲明!

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



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