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即成功;maven

以後在項目中正常導入jar包便可:spa

<dependency>
            <groupId>guagua-commons</groupId>
            <artifactId>guagua-commons</artifactId>
            <version>1.0.1</version>
</dependency>
相關文章
相關標籤/搜索