nuxus 3在Maven项目的配置和POM文件的配置

在nuxus 3中的Maven默认会创建三个仓库,这三个仓库的关系如下:

public是release和snapshot的全集,release默认为关闭状态,所以在配置nexus 3时需要将其开启。

下面是具体的配置过程,参考如下:

1、对项目独立设置:

  • 打开项目的 pom.xml 文件:
  • 添加下面内容:
<repositories>
    <repository>
        <id>Nexus</id>
        <name>192.168.0.110-Nexus</name>
        <url>http://192.168.0.110:8081/nexus/content/groups/public/</url>
    </repository>
</repositories>

2、对全局配置进行设置:

  • 打开 maven 的 settings.xml 文件:
  • 添加下面内容:
<mirrors>
    <mirror>
        <id>Nexus</id>
        <name>Nexus</name>
        <mirrorOf>*</mirrorOf>
        <url>http://192.168.0.110:8081/nexus/content/groups/public/</url>
    </mirror>
</mirrors>

3、持续集成自动构建后发布到 Nexus 上

  • 在 Maven 的 settings.xml 加上连接服务器信息:
<!--设置私库认证信息-->  
<servers>  
    <server>  
        <id>nexus-releases</id>  
        <username>admin</username>  
        <password>admin123</password>  
    </server>  
    <server>  
        <id>nexus-snapshots</id>  
        <username>admin</username>  
        <password>admin123</password>  
    </server>  
</servers>  
  • 在项目的 pom.xml 文件加上:
<!-- nexus-releases nexus-snapshots 与 Maven 的配置文件 settings.xml 中 server 下的 id 对应 -->  
<distributionManagement>  
    <repository>  
        <id>nexus-releases</id>  
        <name>Nexus Releases Repository</name>  
        <url>http://192.168.0.110:8081/nexus/content/repositories/releases/</url>  
    </repository>  
    <snapshotRepository>  
        <id>nexus-snapshots</id>  
        <name>Nexus Snapshots Repository</name>  
        <url>http://192.168.0.110:8081/nexus/content/repositories/snapshots/</url>  
    </snapshotRepository>  
</distributionManagement>

然后就可以使用mvn deploy进行发布了。

对于一些没有源码的包,也就是三方库,需要deploy时,可以使用以下命令行直接上传,在nexus 3中无法在后台自行上传,这个功能已经被干掉。
mvn deploy:deploy-file -DgroupId=com.gexin.platform \
-DartifactId=gexin-rp-sdk-base \
-Dversion=2.0.0.26 \
-Dpackaging=jar \
-Dfile=xxx.jar \
-DrepositoryId=(settings.xml中server对应的id,提供认证信息) \
-Durl=账号对应的发送url(relase|snapshots)

 

 

转载于:https://www.cnblogs.com/EasonJim/p/9950165.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值