maven项目打包发布到私有仓库

在项目开发中通常会引用其他的jar,怎样把自己的项目做为一个jar包的形式发布到私服仓库中,主要有以下三个步骤

(怎样配置maven私服仓库,就不再这里说明了,可以参考以前的文章)1.在maven的setting.xml中配置用户名和密码:

<servers>
    <server>
        <username>admin</username>
        <password>admin123</password>
        <id>nexus-release</id>
    </server>
    <server>
        <username>admin</username>
        <password>admin</password>
        <id>nexus-snapshots</id>
    </server>
</servers>
注意:要在nexus中打开相应的snapshots和releases仓库中的允许发布的开关

2.在发布的项目中配置pom.xml 

如果有parent只需在parent中的pom.xml中配置,没有则在本项目的pom.xml配置即可
<distributionManagement>
<repository>
<id>nexus-release</id>
<url>http://192.168.0.247/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>http://192.168.0.247/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement> <!--上传source.jar 非必须 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

3.在依赖的项目添加依赖(注意版本是snapshot还是release)

snapshot版本还是release版本取决于发布项目中的配置

例如

<properties>
<!-- 依赖的版本定义 -->
<mes.version>0.0.1-RELEASE</mes.version>
</properties>
<dependencies>
<!-- 系统消息服务 -->
<dependency>
<groupId>com.longda.message</groupId>
<artifactId>mes-core</artifactId>
<version>${mes.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

</dependencies>

相应的待发布项目中配置如下

<modelVersion>4.0.0</modelVersion>
<groupId>com.longda.message</groupId>
<artifactId>mes-core</artifactId>
<version>0.0.1-RELEASE</version>
<packaging>jar</packaging>
<name>mes-core</name>
<url>http://maven.apache.org</url>
<properties>
<project.release.version>0.1-RELEASE</project.release.version>

</dependencies>

注意:简而言之就是两边的版本一定要对应上,至于是发布snapshot版本还是release版本需要在第二步中指定

 

转载于:https://my.oschina.net/caryliu/blog/264518

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值