首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Maven私服

Maven私服

作者头像
suveng
发布2019-09-17 10:30:25
1.5K0
发布2019-09-17 10:30:25
举报

Maven私服

环境

centos7

Docker version 18.06.3-ce, build d7080c1

sonatype/nexus3:3.18.1

搭建方式

  • 二进制包搭建
  • docker搭建

docker搭建

  • docker pull sonatype/nexus3:3.18.1
  • mkdir -p /docker/nexus-data && chown -R 200 /docker/nexus-data 创建挂在数据的目录.
  • docker run -d --restart=always --name nexus -p 8081:8081 -v /docker/nexus-data:/nexus-data sonatype/nexus3:3.18.1 -d 后台运行 --restart=always 开机启动 --name docker的container的名字 -v 挂载本地文件系统路径 -p 挂载端口
  • 查看默认账号密码 查看cat /docker/nexus-data/admin.password
  • 登录
image-20190914165029614
image-20190914165029614
  • 改密码 admin/admin
image-20190914165153704
image-20190914165153704
image-20190914165213522
image-20190914165213522

配置

  • 中央仓库代理配置
image-20190914165635906
image-20190914165635906
image-20190914165754825
image-20190914165754825
  • 新建自定义的仓库
image-20190914170041549
image-20190914170041549
image-20190914170245839
image-20190914170245839
image-20190914170600212
image-20190914170600212

使用

  • 对本地 Maven 配置文件 setting.xml 进行配置
    • 设置 server 账户信息每个server元素配置指定的仓库ID和用户信息 <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>${user.home}/.m2/repository</localRepository> <servers> <server> <id>private-release</id> <username>admin</username> <password>admin</password> </server> <server> <id>private-snapshot</id> <username>admin</username> <password>admin</password> </server> </servers> <profiles> <profile> <id>dev</id> <repositories> <repository> <id>private-release</id> <url>http://192.168.9.233:8081/repository/private-release/</url> </repository> <repository> <id>private-snapshot</id> <url>http://192.168.9.233:8081/repository/private-snapshot/</url> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles> </settings>
  • pom.xml配置 <distributionManagement> <repository> <id>private-release</id> <url>http://192.168.9.233:8081/repository/private-release/</url> </repository> <snapshotRepository> <id>private-snapshot</id> <url>http://192.168.9.233:8081/repository/private-snapshot/</url> </snapshotRepository> </distributionManagement> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>8</source> <target>8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
  • 在对应项目执行mvn deploy 这样即可将对应jar包deploy到private-release的私服库中,如下图
image-20190914174045560
image-20190914174045560

备份

只要将挂在的 /docker/nexus-data 里面的数据备份即可

还原

将备份的 /data/nexus-data 数据挂载到 nexus 镜像即可,注意版本的镜像环境变量

可以通过 docker inspect image 即可查到对应镜像的环境参数

资料

https://mp.weixin.qq.com/s/VAAuIF_1JeRa-lmoU481Zg

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年09月14日,如有侵权请联系 cloudcommunity@tencent.com 删除

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

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

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

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