Maven 私服搭建

简介

在使用 Maven 打包项目时我们需要依赖自己或其他同事开发的项目,这些项目在 Maven 中央仓库里是不存在的,我们也不能每次都是以通过编译源码的方式将这些依赖安装到本地仓库中,此时就需要 Maven 私服来帮我解决项目依赖的管理问题

docker-compose.yml

version: '3.1'
services:
  nexus:
    restart: always
    image: shifudao/nexus3
    container_name: nexus
    ports:
      - 8081:8081
    volumes:
      - /usr/local/docker/nexus/data:/nexus-data

登录控制台

地址:http://192.168.75.136:8081/

用户名:admin

密码:admin123

image.png

设置代理仓库

pom.xml 中增加配置

<repositories>
    <repository>
        <id>maven-snapshots</id>
        <name>maven-snapshots</name>
        <url>http://192.168.75.136:8081/repository/maven-snapshots/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
</repositories>

部署管理

pom.xml 中增加配置

<distributionManagement>
    <snapshotRepository>
        <id>nexus</id>
        <name>Nexus Snapshot</name>
        <url>http://192.168.75.136:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
    <repository>
        <id>nexus</id>
        <name>Nexus Releases</name>
        <url>http://192.168.75.136:8081/repository/maven-releases/</url>
    </repository>
</distributionManagement>

配置 Maven 服务器认证

<server>
    <id>nexus</id>
    <username>admin</username>
    <password>admin123</password>
</server>
image.png

部署工程到私服

mvn deploy

部署成功效果图

image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 声明:文章为原创,转载请注明原文地址。http://www.jianshu.com/p/b1fe26d5b8c8文...
    李科吐温阅读 15,975评论 15 33
  • 首先私服是一种衍生出来的特殊的Maven远程仓库,构建私服的好处请看3.5私服 可以帮助大家建立私服的仓库管理软件...
    zlcook阅读 13,623评论 0 32
  • 课程知识回顾 第一个阶段回顾 服务器硬件知识作为运维工作人员的3点职责:1, 保证数据不丢失2,保证服务7*24小...
    醉心萌阅读 1,534评论 0 0
  • 104班交评作业规则: 交评作业——前日提交不出局,当日作业雨,次日点评完——例:6日交不出局,7日作业雨,8日点...
    玫瑰云he阅读 2,915评论 0 0
  • 本文参加#见字如面·寸草春晖#征文活动,文章为作者原创。 作者:侯宝花 学校:山西师范大学现代文理学院 联系...
    别差点阅读 2,415评论 0 0