方法一(推荐):
<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:messageguagua-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>