docker搭建maven私服

1,安装 Docker

移除旧的版本:

$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

安装一些必要的系统工具:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

添加软件源信息:

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

更新 yum 缓存:

sudo yum makecache fast

安装 Docker-ce:

sudo yum -y install docker-ce

启动 Docker 后台服务

sudo systemctl start docker

2,下载nexus3的镜像

docker pull sonatype/nexus3

3.将容器内部/var/nexus-data挂载到主机/root/nexus-data目录。

docker run -d -p 8081:8081 --name nexus -v /root/nexus-data:/var/nexus-data --restart=always sonatype/nexus3

4,等一分钟,查看容器信息,docker inspect 容器id ,可以看到IPAddress说明启动成功


再,curl localhost:8081,会返回html页面标签

访问:http://192.168.154.132:8081

点击登录:用户名:admin,密码 :admin123

如果登录不上,默认密码变了

进入容器内部: docker exec -it c5c48a242815 bash

进入密码路径:/opt/sonatype/sonatype-work/nexus3

再修改密码配置:vi admin.password,保存后退出:exit

重启nexus容器:docker restart c5c48a242815 ,等待1分钟左右,再curl localhost:8081

再登录,发现修改的密码不生效,于是直接复制admin.password文件的密码

发现登录成功,第一次登录会提示修改密码。

5,nexus私服操作,默认会读取central中央仓库,当然也可以自己创建私有仓库

6,创建私有仓库

Allow redeploy:选择允许上传jar,注意修改Hosted下的下拉框

 

创建用户

用刚才创建的用户登录

8,上传jar到私有仓库(上传到yingyinqi-release)

1,修改maven中的setting.xml,添加以下内容

 <!--id随便填,用户名和密码填users中的用户名密码-->
    <server>
      <id>testMavenDeploy</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

2,项目的maven中加入如下配置(实际开发中会把repository放入maven的settings.xml中)

  <!--注意限定版本一定为RELEASE,因为上传的对应仓库的存储类型为RELEASE -->
  <!--指定仓库地址 -->
  <distributionManagement>
    <repository>
      <!--此名称要和.m2/settings.xml中设置的ID一致 -->
      <id>testMavenDeploy</id>
      <url>http://192.168.154.132:8081/repository/yingyinqi-release/</url>
    </repository>
  </distributionManagement>

  <build>
    <plugins>
      <!--发布代码Jar插件 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.7</version>
      </plugin>
      <!--发布源码插件 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>2.2.1</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

注意:version中不能含有不能还有SNAPSHOT,代表测试版本,release代表正式版本

然后在idea 的terminal中输入mvn clean deploy,即可上传

9,引入刚才上传的jar包,只要在项目中添加dependency依赖

    <dependencies>
        <dependency>
            <groupId>com.maven</groupId>
            <artifactId>testdeploy</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>testMavenDeploy</id>
            <url>http://192.168.154.132:8081/repository/yingyinqi-release/</url>
        </repository>
    </repositories>

10,如何判断maven私服的文件是否发生改变

当然是用比较文件hash值的方法,文件hash又叫文件签名,文件中哪怕一个bit位被改变了,文件hash就会不同。比较常用的文件hash算法有MD5和SHA-1

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值