gitee变成maven私库

1、背景

当由于各种原因,比如网络、想控制谁有权限访问类库或者公司没有服务器作为私库等,可以采用此法。

2、Gitee建新的仓库

我的仓库地址:https://gitee.com/min290/warm-flow-repo.git

2.1、首先要建立仓库

img

2.2、仓库选择开源,否则无法下载

img

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”

img

改为如下,重新加载依赖,如还为生效,可能缓存原因,重启idea。

img

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值