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