宁波做外贸网站,上海人才市场档案存放中心,wordpress标题去重,51zwd一起做网站什么是Maven私服#xff1f;
Maven 私服是一种特殊的Maven远程仓库#xff0c;它是架设在局域网内的仓库服务#xff0c;用来代理位于外部的远程仓库#xff08;中央仓库、其他远程公共仓库#xff09;。
当然也并不是说私服只能建立在局域网#xff0c;也有很多公司会…什么是Maven私服
Maven 私服是一种特殊的Maven远程仓库它是架设在局域网内的仓库服务用来代理位于外部的远程仓库中央仓库、其他远程公共仓库。
当然也并不是说私服只能建立在局域网也有很多公司会直接把私服部署到公网具体还是得看公司业务的性质是否是保密的等等因为局域网的话只能在公司用部署到公网的话员工在家里也可以办公使用。
建立了 Maven 私服后当局域网内的用户需要某个构件时会按照如下顺序进行请求和下载。
请求本地仓库若本地仓库不存在所需构件则跳转到第 2 步 请求 Maven 私服将所需构件下载到本地仓库若私服中不存在所需构件则跳转到第 3 步。 请求外部的远程仓库将所需构件下载并缓存到 Maven 私服若外部远程仓库不存在所需构件则 Maven 直接报错。 此外一些无法从外部仓库下载到的构件也能从本地上传到私服供其他人使用。
Maven 私服优势
Maven 私服具有以下 5 点优势
节省外网带宽大量对于外部远程仓库的重复请求会消耗很大量的带宽利用 Maven私服代理外部仓库后能够消除对外部仓库的大量重复请求降低外网带宽压力。下载速度更快Maven 私服位于局域网内从私服下载构建更快更稳定。 便于部署第三方构件有些构件是无法从任何一个远程仓库中获得的例如某公司或组织内部的私有构件、Oracle 的 JDBC 驱动等建立私服之后就可以将这些构件部署到私服中供内部 Maven 项目使用。提高项目的稳定性增强对项目的控制如果不建立私服那么 Maven 项目的构件就高度依赖外部的远程仓库若外部网络不稳定则项目的构建过程也会变得不稳定。建立私服后即使外部网络状况不佳甚至中断只要私服中已经缓存了所需的构件Maven 也能够正常运行。此外还提供了很多额外控制功能例如权限管理、RELEASE/SNAPSHOT 版本控制等可以对仓库进行一些更加高级的控制。降低中央仓库得负荷压力由于私服会缓存中央仓库得构件避免了很多对中央仓库的重复下载降低了中央仓库的负荷。
环境要求
需要先安装 1.docker 2.jdk
安装Nexus
下载一个nexus3的镜像
docker pull sonatype/nexus3使用nexus3镜像创建并启动一个容器然后指定暴露18091端口到对应主机的18091端口:
docker run -d -p 18091:18091 --name nexus -v /backup/nexus-data:/var/nexus-data --restartalways sonatype/nexus3查看启动容器的状态
docker ps查看容器日志
docker logs -f -t 容器名称id由于nexus的默认端口为8081我们在启动的时候改为18091后需要修改nexus的配置文件
先进入容器
docker exec -it 容器名称 bash修改配置文件
vi /opt/sonatype/nexus/etc/nexus-default.properties 同时查看admin密码
vi /nexus-data/admin.password这样就可以在本地浏览器进入nexus页面了地址为 服务器ip:18091
右上角登录用户名为admin,密码为之前查看的密码。
浏览器访问配置仓库
删除nuget开头的仓库 配置maven-central的代理地址
阿里代理地址http://maven.aliyun.com/nexus/content/groups/public/
配置本地maven的settings.xml
servers标签修改 仓库权限用户名和密码 server idmaven-releases/id usernameadmin/username passwordwubuer2021/password /serverserver idmaven-snapshots/id usernameadmin/username passwordwubuer2021/password /servermirrors添加仓库中group类型的仓库 mirror idnexus/id nameinternal nexus repository/name urlhttp://119.3.90.18:18091/repository/maven-public//url mirrorOfcentral/mirrorOf /mirror profiles添加仓库中仓库信息 profile idnexus/id repositories repository idmaven-public/id urlhttp://119.3.90.18:18091/repository/maven-public//url releasesenabledtrue/enabled/releases snapshotsenabledtrue/enabled/snapshots /repository repository idmaven-snapshots/id urlhttp://119.3.90.18:18091/repository/maven-snapshots//url releasesenabledtrue/enabled/releases snapshotsenabledtrue/enabled/snapshots /repository /repositories pluginRepositories pluginRepository idmaven-releases/id urlhttp://119.3.90.18:18091/repository/maven-releases//url releasesenabledtrue/enabled/releases snapshotsenabledtrue/enabled/snapshots /pluginRepository pluginRepository idmaven-snapshots/id urlhttp://119.3.90.18:18091/repository/maven-snapshots//url releasesenabledtrue/enabled/releases snapshotsenabledtrue/enabled/snapshots /pluginRepository /pluginRepositories /profile配置pom.xml
添加标签 distributionManagementrepositoryidmaven-releases/idname Nexus Release Repository /nameurl http://119.3.90.18:18091/repository/maven-releases/ /url/repositorysnapshotRepositoryidmaven-snapshots/idname Nexus Snapshot Repository /nameurl http://119.3.90.18:18091/repository/maven-snapshots/ /url/snapshotRepository/distributionManagement