前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >将构件发布到私有的nexus maven 仓库

将构件发布到私有的nexus maven 仓库

作者头像
前Thoughtworks-杨焱
发布2021-12-08 08:58:16
5110
发布2021-12-08 08:58:16
举报
文章被收录于专栏:杨焱的专栏

1、settings.xml 中配置用户名密码

代码语言:javascript
复制
<server>
    <id>deploymentRepo</id>
    <username>repouser</username>
    <password>repopwd</password>
</server>

2、pom.xml中配置 distributionManagement块,执行deploy就可以了

3、如果要发布到 snapshotRepository的话,只需要保证项目的版本最后是-SNAPSHOT结尾就会在发布的时候自动发布到配置的snapshotRepository下。

默认的nexus用户名是admin密码是admin123,登录后可以看到有一个depolyment用户,可以设置一个密码,然后用depolyment的用户来发布到我们自己的nexus私有仓库。本文使用nexus这个名字作为私服的主机名。如果你也想直接使用nexus访问到私服,可以设置hosts文件。

下面我列出在项目中的pom:

代码语言:javascript
复制
<repositories>
    <!-- 本地稳定版本构件库-->
    <repository>
        <id>releases</id>
        <name>releases</name>
        <url>http://nexus:8081/nexus/content/repositories/releases</url>
    </repository>
    <!-- 本地临时版本构件库-->
    <repository>
        <id>snapshots</id>
        <name>snapshots</name>
        <url>http://nexus:8081/nexus/content/repositories/snapshots</url>
    </repository>
</repositories>


<!-- 发布到本地镜像仓库 -->
<distributionManagement>
    <repository>
        <id>releases</id>
        <name>releases</name>
        <url>http://nexus:8081/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>snapshots</name>
        <url>http://nexus:8081/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>

配合使用profiles可以灵活的区分不同的环境动态设置配置

代码语言:javascript
复制
<profiles>
    <profile>
        <id>dev</id>
        <properties>
            <jdbc_driverClass>com.mysql.jdbc.Driver</jdbc_driverClass>
            <jdbc_host>localhost</jdbc_host>
            <jdbc_port>3306</jdbc_port>
            <jdbc_dbname>test</jdbc_dbname>
            <jdbc_username>root</jdbc_username>
            <jdbc_password>123456</jdbc_password>

        </properties>
    </profile>

    <profile>
        <id>linux</id>
        <activation>
            <os>
                <family>linux</family>
            </os>
        </activation>
        <properties>
            <log4j_log_path>/var/log</log4j_log_path>
        </properties>
    </profile>
</profiles>

同时如果直接从远程仓库下载依赖太慢,在开发团队中,使用nexus开启central的proxy仓库是一个很好的办法,开启的办法很简单,就是使用admin登录nexus的后台,然后设置Central的配置,讲下载索引的开关打开,并且将这个仓库添加到Publish的列表中,然后在本地的maven配置文件中,设置mirror。

代码语言:javascript
复制
<mirror>
<id>centralMirror</id>
<mirrorOf>central</mirrorOf>
<name>Central Repository Mirror Server.</name>
<url>http://nexus:8081/nexus/content/repositories/central</url>
</mirror>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2015-07-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档