1、背景
当由于各种原因,比如网络、想控制谁有权限访问类库或者公司没有服务器作为私库等,可以采用此法。
2、Gitee建新的仓库
我的仓库地址:https://gitee.com/min290/warm-flow-repo.git
2.1、首先要建立仓库
2.2、仓库选择开源,否则无法下载
3、下载此项目
比如我的下载到:D:/IdeaProjects/min/warm-flow-repo
4、上传私库的到本地
上传命令:mvn clean deploy -P gitee
配置介绍:
distributionManagement:此配置上传到本地的路径
maven-source-plugin:打包附带源码
maven-javadoc-plugin:打包附带api文档
<profile>
<id>gitee</id>
<build>
<plugins>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<!-- 忽略生成文档中的错误 -->
<additionalparam>-Xdoclint:none</additionalparam>
<aggregate>true</aggregate>
<charset>UTF-8</charset><!-- utf-8读取文件 -->
<encoding>UTF-8</encoding><!-- utf-8进行编码代码 -->
<docencoding>UTF-8</docencoding><!-- utf-8进行编码文档 -->
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>gitee-snapshots</id>
<url>file:D:/IdeaProjects/min/warm-flow-repo/snapshots</url>
</snapshotRepository>
<repository>
<id>gitee-releases</id>
<name>releases</name>
<url>file:D:/IdeaProjects/min/warm-flow-repo/releases</url>
</repository>
</distributionManagement>
</profile>
</profiles>
5、下载依赖
在pom.xml的project目录下新增如下配置
<repositories>
<repository>
<id>Gitee-Warm-Flow</id>
<url>https://gitee.com/min290/maven-repository/raw/main/releases</url>
</repository>
</repositories>
需要注意:如果没有此配置没有生效,还是走maven中setting的镜像仓库,需要查看,mirrorOf是否位“*”,此代码拦截所有仓库,需要增加排除“!Gitee-Warm-Flow”
改为如下,重新加载依赖,如还为生效,可能缓存原因,重启idea。