首页 > 其他 > 详细

07 Maven私服仓库

时间:2020-10-26 21:22:40      阅读:33      评论:0      收藏:0      [点我收藏+]

私服安装和启动

一、私服介绍

Nexus是Maven仓库管理器,通过nexus可以搭建maven仓库,同时nexus还提供强大的仓库管理功能,构建搜索功能等

二、安装私服步骤

2.1、下载私服

下载nuxus,下载地址:http://www.sonatype.org/nexus/archived/

技术分享图片

2.2、安装nexus

解压nexus-2.12.0-01.zip,进入bin目录

技术分享图片

如果是win7找到附件cmd窗口右键管理员运行,执行neuxs.bat install

技术分享图片

安装完成在服务正查看nexus服务

技术分享图片

2.3、卸载nexus

卸载是nexus.bat uninstarll

查看windows服务列表nexus已被删除

三、启动私服

方式一:cmd进入bin目录,执行nexus.bat start

方式二:

直接启动nexus服务,查看nexus的配置文件conf/nexus.properties

# Jetty section
application-port=8081 #nexus的访问端口设置
application-host=0.0.0.0 #nexus主机监听配置
nexus-webapp=${bundleBasedir}/nexus #nexus工作目录
nexus-webapp-context-path=/nexus #nexus的web访问路径
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus #nexus仓库目录
runtime=${bundleBasedir}/nexus/WEB-INF #nexus运行程目录

四、访问私服

打开浏览器输入http://localhost:8081/nexus/

技术分享图片

4.1、登录私服

技术分享图片

点击log in登录。用户名是admin/admin123

五、私服介绍

技术分享图片

  • hosted,宿主仓库, 部署自己的 jar 到这个类型的仓库,包括 releases 和 snapshot 两部分, Releases 公司内部发布版本仓库、 Snapshots 公司内部测试版本仓库

  • proxy,代理仓库, 用于代理远程的公共仓库,如 maven 中央仓库,用户连接私服,私服自动去中央仓库下载 jar 包或者插件。

  • group,仓库组,用来合并多个 hosted/proxy 仓库,通常我们配置自己的 maven 连接仓库组。

  • virtual(虚拟):兼容 Maven1 版本的 jar 或者插件

    技术分享图片

六、将项目发布到私服

需求:企业中多个团队协作开发通常会将一些共用的软件、开发模块等发布到私服供其他团队或模块人员使用

6.1、配置

1、需要在客户端即部署ssm_dao工程的电脑上配置maven环境,并修改maven/conf/settings.xml文件,配置连接私服的用户和密码

此用户名和私服用于私服校验,因为私服需要知道上传的账户和密码是否和私服中的账户和密码一致

<server>
    <id>releases</id>
    <username>admin</username>
    <password>admin123</password>
</server>
<server>
    <id>snapshots</id>
    <username>admin</username>
    <password>admin123</password>
</server>
  • releases:连接发布版本项目仓库
  • snapshots:连接测试版本项目仓库

2、配置项目pom.xml

配置私服仓库,本公司的自己的jar包会上传到私服的宿主仓库,根据工程的版本号决定上传到哪个宿主仓库,如果版本为release则上传到release仓库,如果版本为snapashot则上传到私服的snapshot仓库

<distributionManagement>
    <repository>
        <id>releases</id>
        <url>http://localhost:8081/nexus/content/repositories/releases/</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>

注意:pom.xml这里<id>和settings.xml配置<id>对应

3、将项目打包上传

![b518beb29c15ac53bede42816b7b8de8.jpeg](file:///C:/Users/zhiqiangYi/Documents/My Knowledge/temp/48772bb4-b3fa-4c19-a7d5-04fb6ab5ba4c/128/index_files/clip_image001a6dda111-5a1f-4089-a8ce-2956c6e62c87.jpg)

4、查看项目是否上传到私服中

七、从私服中下载

<!-- 下载jar包配置 -->
<profile>
    <!--profile的id -->
    <id>dev</id>
    <repositories>
        <repository> <!--仓库id,repositories可以配置多个仓库,保证id不重复 -->
            <id>nexus</id> <!--仓库地址,即nexus仓库组的地址 -->
            <url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下载releases构件 -->
            <releases>
                <enabled>true</enabled>
            </releases> <!--是否下载snapshots构件 -->
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories> <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
        <pluginRepository> <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
            <id>public</id>
            <name>Public Repositories</name>
            <url>http://localhost:8081/nexus/content/groups/public/</url>
        </pluginRepository>
    </pluginRepositories>
</profile>
<activeProfiles>
    <activeProfile>dev</activeProfile>
</activeProfiles>
<activeProfile>dev</activeProfile>

07 Maven私服仓库

原文:https://www.cnblogs.com/xianbeier/p/13880794.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!