• windowns下 Maven 环境的配置及Nexus私服搭建


    1.下载Maven

         地址: http://maven.apache.org/download.cgi 

         使用版本为:apache-maven-3.0.5-bin.zip

    1.2 解压Maven并添加到环境变量

      变量名 M2_HOME

      变量值:D:Program FilesApache Software Foundationapache-maven-3.0.5

      添加到 Path %M2_HOME%in;

          如果出现如下错误,请设置 JAVA_HOME

      please set the JAVA_HOME variable in you environment

         cmd     mvn  -v  出现如下信息及安装成功

       

       2 安装Maven私服 Nexus

      下载地址:http://www.sonatype.org/downloads/nexus-latest-bundle.zip

           苦x博主网络差 下不下来,想来安装也是一样一样的

          这里就用 1.9的版本了

          下载地址:http://nexus.sonatype.org/downloads/nexus-oss-webapp-1.9.0.1-bundle.zip

          2.1 安装

        简单解压缩下载的zip包到安装目录就可以了
           可执行文件在%nexus安装目录% exus-webapp-1.0.0injswwindows-x86-32下:
        InstallNexus.bat/UninstallNexus.bat是安装/卸载nexus为windows service,

                如果需要设置nexus为开机自动启动就可以安装为windows service然后设置启动方式为自动。
        Nexus.bat是直接在命令行中启动Nexus,如果不想安装Nexus为windows
        service,可以用这个文件来手工控制Nexus的启动退出。
      2.2 配置nexus
        首先登录,默认地址http://localhost:8081/nexus/,默认用户名密码为admin/admin123.
          最重要的一件事情就是开启远程索引下载,索引这个功能实在是太好用了。
        nexus默认是关闭远程索引下载功能的,主要是担心会造成对服务器的巨大负担,需要我们手工开启。
        开启的方式:
          点击Administration菜单下面的Repositories,将这三个仓库Apache
            Snapshots,Codehaus Snapshots,Maven
            Central的Download Remote Indexes修改为true。然后在这三个仓库上分别右键,选择Re-index,这样Nexus就会去下载远程的索引文件。

        注意:如果出现错误 1067 进程意外终止  无法启动 nexus 错误。

        JAVA_HOME和PATH两个环境变量必须设置成系统变量,而非用户变量

       最新版本的 nexus 请确定 JDK为1.7.

        或者下载 2.1.1 对于 JDK1.6是完全支持滴

         Nexus所有版本下载地址:http://www.sonatype.org/nexus/archived

           2.3 配置setting.xml文件

          设置Maven仓库位置

          

    <localRepository>D:/Program Files/Apache Software Foundation/Apache/.m2/repository</localRepository>

           在<profiles></profiles>标签中增加nexus的profile

        

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


             修改activeProfiles

     

    <activeProfiles>
            <activeProfile>nexus</activeProfile>
          </activeProfiles>

    3. 如果公司通过代理上网给 Maven设置代理如下

      然后 mvn  help:system 从服务器下载jar档。

    出现如下警告

    在settings.xml 中添加代理设置

     <proxies>
        <proxy>  
          <id>my-proxy</id>  
          <active>true</active>  
          <protocol>http</protocol>  
          <host>88.120.0.10</host>  
          <port>8089</port>   
        </proxy> 
      </proxies>

      

  • 相关阅读:
    P4141 消失之物(退背包模板)
    P5829 【模板】失配树
    P4827 [国家集训队] Crash 的文明世界
    P4074 [WC2013]糖果公园
    P3242 [HNOI2015]接水果
    P2371 [国家集训队]墨墨的等式
    P4819 [中山市选]杀人游戏
    P5331 [SNOI2019]通信
    BZOJ1082 [SCOI2005]栅栏
    poj1475 Pushing Boxes[双重BFS(毒瘤搜索题)]
  • 原文地址:https://www.cnblogs.com/yehshuai/p/3446775.html
Copyright © 2020-2023  润新知