今天遇到一个mavan仓库中没有的jar包, 故只能添加本地jar包, 花了不少时间找资料,终于OK。故在此记录。
1. 第一次,在网上看到说可以用<systemPath> 解决, 如下:
![复制代码](http://static.oschina.net/uploads/img/201502/25102851_YBw9.gif)
xxx xxx xxx system ${basedir}/xx.jar
![复制代码](http://static.oschina.net/uploads/img/201502/25102851_YBw9.gif)
但是,在运行jetty 的以及打包的时候,会找不到引用的包,直接pass掉。各种蛋疼,都是maven不熟惹的祸。故去maven官网看了一下文档,捣鼓了好一阵儿,终于找到了一个解决办法:
2. 创建本地仓库,以plugin的形式进行安装:
(1)创建本地仓库:
![复制代码](http://static.oschina.net/uploads/img/201502/25102851_YBw9.gif)
local-repo file://${basedir}/repo
![复制代码](http://static.oschina.net/uploads/img/201502/25102851_YBw9.gif)
(2)将本地库安装到maven:
mvn install:install-file -Dfile=-DgroupId= -DartifactId= -Dversion= -Dpackaging= -DlocalRepositoryPath=
(注:参数说明:jar-path 为你的jar所在路径, group,artifactId, version 这个不多说, packaging 为jar或war, DlocalRepositoryPath是你之前创建的本地仓库的路径)。
(3) 以插件形式安装:
![复制代码](http://static.oschina.net/uploads/img/201502/25102851_YBw9.gif)
org.apache.maven.plugins maven-install-plugin 2.4 initialize install-file xxx xxx xxx jar ${basedir}/xxx.jar
![复制代码](http://static.oschina.net/uploads/img/201502/25102851_YBw9.gif)
(4) 添加依赖:
xxx xxx xxx
ok, 到此就ok啦。 由于对maven不是太熟,的确花了不少时间去看资料。特在此记录,一来留个笔记,而来希望能帮助到遇到同样问题的人。