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