记一次maven打包到私库,然后从私库拉取到另外工程的坑

项目有些公共功能模块类似common,api等打成jar包,方便其它项目引入使用。

1,在自己要打成jar包的工程的pom文件里面加入公司的私库地址。(ps:记得你要打包的工程的pom文件里面不要加入其它私库没有的父模块,不然打包后,其它工程拉取不到,因为你的父工程不一定上传到私库了)。

<parent>
    <groupId>xxxx.xxxxxx</groupId>
    <artifactId>xxxxx-com-parent</artifactId>
    <version>2.7.0</version>
</parent>

)

pom文件加入

<distributionManagement>
    <snapshotRepository>
        <id>maven-snapshots</id>
        <url>http://xxxxx:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
</distributionManagement>

maven的setting.xml配置里面增加对应私库服务的用户名跟密码配置。

<server>  
          <id>maven-snapshots</id>  
          <username>xxxxxxx</username>  
          <password>xxxxxxx</password>  
 </server> 

pom文件里面的 id配置maven-snapshots对应你maven setting.xml里面的 server下面的id。这样就可以在IDEAL里面找到对应要上传到私库的工程,点击deploy打包上传。

2,在另外工程里面引入时,在pom文件里面增加对应私库的地址。

<repositories>
    <repository>
        <!-- ID必填 -->
        <id>maven-snapshots</id>
        <!-- Maven私服SNAPSHAT仓库URL,这里需要替换为实际公司的私服地址 -->
        <url>http://xxxxxxx/repository/maven-snapshots</url>
        <!-- 设置启用SNAPSHOT -->
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

如果此时拉取不到,在到maven的setting.xml里面去配置一下。

<profiles>

 <!-- 阿里云配置: 提高国内的jar包下载速度 -->
        <profile>
            <id>aliyun-Repository</id>
            <repositories>
                <repository>
                    <id>aliyun</id>
                    <url>>http://maven.aliyun.com/nexus/content/groups/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>

<profile>
            <id>maven-snapshot-Repository</id>
            <repositories>
                <repository>
                    <id>maven-snapshots</id>
                    <url>http://xxxxx:8081/repository/maven-snapshots</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>
    
 <activeProfiles>
        <activeProfile>aliyun-Repository</activeProfile>
        <!--<activeProfile>java-group-Repository</activeProfile>-->
        <activeProfile>maven-snapshot-Repository</activeProfile>
 </activeProfiles>

最终,在别的工程里面终于可以拉取到jar包了。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JB091

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值