docker搭建Maven私服

基于docker安装Maven私服仓库


yum源安装docker

  1. 查看是否已安装docker列表

yum list installed | grep docker

  1. yum安装docker

yum -y install docker

在这里插入图片描述

  1. 启动docker

systemctl start docker

  1. 查看docker服务状态

systemctl status docker

在这里插入图片描述


nexus3的镜像

  1. 下载一个nexus3的镜像

docker pull sonatype/nexus3

  1. 将容器内部/var/nexus-data挂载到主机/root/nexus-data目录。内部和外部端口号8081

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

  1. 查看容器ID

docker ps

  1. 可以查看正在启动的日志 docker attach + 容器的id

docker attach xxxx容器IDxxx

启动成功

在这里插入图片描述

关闭防火墙

service iptables stop

访问地址

http://192.x.x.x:8081

Maven默认账号密码

  1. 进入到容器中

docker exec -it xxxx容器IDxxx bash

  1. 进入 admin.password 查看密码

cat /nexus-data/admin.password

注意 bash-4.4$ 这个不要复制

在这里插入图片描述

账号:admin
密码:0e54da2c-338a-49f3-abf0-c021a07f33c3

创建Maven仓库

在这里插入图片描述

正式版本

在这里插入图片描述
控制是否允许对工件进行部署和更新
Controls if deployments of and updates to artifacts are allowed

在这里插入图片描述

配置本地settings.xml

<servers>
  
	<server>
      <id>admin</id>
      <username>admin</username>
      <password>admin</password>
    </server>
    
  </servers>

在这里插入图片描述

项目配置文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>tst-xxx</artifactId>
        <groupId>org.tst</groupId>
        <version>1.0-RELEASE</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <artifactId>tst-xxx-xx</artifactId>

    <packaging>jar</packaging>

    <description>tst xxx</description>

    <dependencies>

        <!-- Hu-tool是一个小而全的Java工具类库 -->
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>${hutool.version}</version>
        </dependency>

        <!-- Http Client -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>

    </dependencies>

    <!--注意限定版本一定为RELEASE,因为上传的对应仓库的存储类型为RELEASE -->
    <!--指定仓库地址 -->
    <distributionManagement>
        <repository>
            <!--此名称要和.m2/settings.xml中设置的ID一致 -->
            <id>admin</id>
            <url>http://192.168.203.128:8081/repository/tst-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>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


</project>

Maven 执行命令 上传jar包即可

mvn deploy

注意版本号码一定要是为:release版本 ,否则上传jar报错

本地项目引入maven私服jar

	<dependencies>
		<dependency>
			<groupId>com.tst</groupId>
			<artifactId>tst-xxx-xx</artifactId>
			<version>1.0-RELEASE</version>
		</dependency>
	</dependencies>

	<!-- 指定私服仓库地址 -->
	<repositories>
		<repository>
			<id>admin</id>
			<url>http://192.168.203.128:8081/repository/tst-RELEASE</url>
		</repository>
	</repositories>

如何判断文件是否发生改变

如何知道一个文件是否改变了呢?
当然是用比较文件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、付费专栏及课程。

余额充值