配置本地maven仓库

2023-07-31  本文已影响0人  hongzhenw

云端maven仓库不方便配置的话,在本地配置也是个不错的选择,方便管理与移植。

步骤

  1. 下载个maven文件,比如apache-maven-3.9.3-bin.zip
  2. 解压到电脑本地
  3. 编辑apache-maven-3.9.3/conf/settings.xml文件,修改如下:
# xxx路径改成自己本地的
<localRepository>xxx\apache-maven-3.9.3\repository</localRepository>

使用

比如,IntelliJ IDEA,设置-》搜索maven

User settings file:xxx\apache-maven-3.9.3\conf\settings.xml
Local respository:xxx\apache-maven-3.9.3\repository

三方jar放到本地maven仓库

  1. 执行以下命令,把jar放到仓库内
# 示例
mvn install:install-file -Dfile=C:Users\xxx\xxx.jar -DgroupId=com.my.groupId -DartifactId=my.artifacetId -Dversion=1.0.0 -Dpackaging=jar

命令说明

-Dfile:jar路径
-DgroupId:自定义groupId
-DartifactId:自定义artifactId
-Dversion:自定义版本
-Dpackaging:默认jar

执行成功,如截图


image.png
  1. 使用,比如,pom.xml引用
<dependency>
    <groupId>com.my.groupId</groupId>
    <artifactId>my.artifacetId</artifactId>
    <version>1.0.0</version>
</dependency>
上一篇 下一篇

猜你喜欢

热点阅读