在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>

 

 本地jar添加到maven仓库中

 

 

相关文章:

  • 2021-11-19
  • 2021-12-22
  • 2021-11-12
  • 2021-09-27
  • 2021-06-08
  • 2021-10-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2021-06-09
  • 2021-09-03
相关资源
相似解决方案