本地jar添加到maven仓库中

在pom.xml中添加依赖

<dependency>
    <groupId>com.rxtx</groupId>
    <artifactId>rxtx-comm</artifactId>
    <version>1.0.0</version>
</dependency>
groupId,artifactId,version这些都是自己设置的

maven命令将jar包移动到maven的本地repository中

mvn install:install-file -Dfile=jar包的位置(参数一) -DgroupId=groupId(参数二) -DartifactId=artifactId(参数三) -Dversion=version(参数四) -Dpackaging=jar

参数一
是jar包的位置

参数二 是在pom.xml中对应的groupId
参数三 是在pom.xml中对应的artifactId
参数四 是在pom.xml中对应的version

验证方法:m2\repository 查看

第二种方法:不把jar添加到maven本地仓库也能在maven工程下使用外部jar包

将包htmlparser.jar放入了项目下的lib目录中
    -> ${project}/lib/htmlparser.jar
pom.xml文件中依赖
<dependency>
    <groupId>com.rxtx</groupId>
    <artifactId>rxtx-comm</artifactId>
    <version>1.0.0</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/lib/rxtx.jar</systemPath>
</dependency>

 

 

 

 
posted @ 2017-06-22 16:56  翔运  阅读(1368)  评论(0编辑  收藏  举报