zoukankan      html  css  js  c++  java
  • windows+nexus+maven环境搭建(转)

    windows nexus环境搭建

    1、下载nexus 版本为 nexus-2.11.4-01-bundle 
    下载地址 这里写链接内容 
    2、将下载好的文件放到D盘进行解压 
    3、解压后目录结构这里写图片描述 
    nexus-2.11.4-01目录包含了Nexus运行所需要的文件。是Nexus运行必须的。

    sonatype-work目录包含Nexus生成的配置文件、日志文件、仓库文件等。当我们需要备份Nexus的时候默认备份此目录即可。

    4、进行环境变量配置,将目录配置到环境变量path中,下图为我的文件存放目录。

    这里写图片描述

    5、切换到该目录执行安装命令 
    (1)nexus install 
    这里写图片描述

    (2)启动nexus 
    nexus start 
    这里写图片描述

    如果启动失败,如下图。该提示信息表示jdk配置不正确,如果nexus高于2.6版本则需要使用jdk1.7以上版本。并在wrapper.conf文件中配置jdk路径 wrapper.java.command=C:Program FilesJavajdk1.7.0_75injava.exe

    这里写图片描述 
    错误信息: 
    这里写图片描述

    错误原因 
    nexus无法启动大概原因为: 
    1.nexus的wrapper.conf文件中的:java配置错误导致启动失败(包括版本错误和路径错误) 解决如上 
    2.nexus的8081端口被占用 
    修改nexus的端口号——找到nexus-2.11.4-01conf下的nexus.properties中的application-port修改自己想要的端口号即可 
    这里写图片描述

    6、启动成功,输入地址 
    http://127.0.0.1:8081/nexus/ 
    这里写图片描述

    二、nexus使用 
    1、Nexus常用功能就是:指定私服的中央地址、将自己的Maven项目指定到私服地址、从私服下载中央库的项目索引、从私服仓库下载依赖组件、将第三方项目jar上传到私服供其他项目组使用。 
    2、仓库管理 
    点击左边导航栏的Repositories,界面的主面板会显示所有一个所有仓库及仓库组的列表,你会看到它们的Type字段的值有group,hosted,proxy,virtual。这里我们不关心virtual,只介绍下另外三种类型: 
    hosted,本地代理仓库,通常我们会部署自己的构件到这一类型的仓库。 
    proxy,代理的远程仓库,它们被用来代理远程的公共仓库,如maven中央仓库。 
    group,仓库组,用来合并多个hosted/proxy仓库,通常我们配置maven依赖仓库组。 
    这里写图片描述

    上传第三方jar 
    这里写图片描述

    这里写图片描述
    这里写图片描述
    3、maven中配置nexus 
    如果只是在一个项目使用可以在pom.xml文件中配置。如果要多个项目同时使用则在maven的setting.xml文件中进行配置。

    要想使用这个私服仓库,先在项目pom中配置相关私服信息

    指定仓库和插件仓库

     <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                  <id>public</id>
                  <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
                  <releases><enabled>true</enabled></releases>
                  <snapshots><enabled>false</enabled></snapshots>
                </repository>
                <repository>
                  <id>public-snapshots</id>
                  <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>
                  <releases><enabled>false</enabled></releases>
                  <snapshots><enabled>true</enabled></snapshots>
                </repository>
          </repositories>
          <pluginRepositories>
              <pluginRepository>
                <id>public</id>
                <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>false</enabled></snapshots>
              </pluginRepository>
              <pluginRepository>
                <id>public-snapshots</id>
                <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>
                <releases><enabled>false</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
              </pluginRepository>
          </pluginRepositories>
          </profile>

    配置mirror 
    Mirror是制定镜像站点 
    id, name是该镜像的唯一定义符。id用来区分不同的mirror元素。 
    url是该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL。 
    mirrorOf是被镜像的服务器的id。例如,如果我们要设置了一个Maven中央仓库(http:// 
    repo1.maven.org/maven2)的镜像,就需要将该元素设置成central。这必须和 
    中央仓库的id central完全一致。

    <mirrors>
         <!--1021-->
            <mirror>
          <id>nexus-public</id>
          <mirrorOf>*</mirrorOf>
          <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
        </mirror>
            <mirror>
          <id>nexus-public-snapshots</id>
          <mirrorOf>Snapshots</mirrorOf>
            <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
        </mirror>
      </mirrors>

    配置权限 表示当需要连接到一个远程服务器的时候需要使用到的验证方式

      <server>
          <id>repo</id>
          <username>admin</username>
          <password>admin123</password>
        </server>
        <server>
          <id>Snapshots</id>
          <username>admin</username>
          <password>admin123</password>
        </server>
      </servers>

    配置activeProfiles

    <activeProfiles>
       <activeProfile>nexus</activeProfile>
      </activeProfiles>
  • 相关阅读:
    file & iconv
    UML类图思考
    Rust PhantomData and dropck rgb
    golang recover rgb
    帮上小学的女儿写的一篇文章春夏秋冬
    SAP B1在添加物料主数据时,出现错误提示‘xxxx代码已存在’的解决方法
    SAP B1外协物料处理方法
    SAP B1外发加工件成本的处理方法(曹玉平于奥莱照明)
    SAP B1存在的BUG
    交叉表的实殃及向SQL SERVER数据库中插入数据时,出现乱码或???(问号)的解决方法。
  • 原文地址:https://www.cnblogs.com/zhangjianbin/p/7771878.html
Copyright © 2011-2022 走看看