• 搭建Maven私服


      最近从SVN下载的代码,在本地构建时出现了诸多问题,部分依赖下载超时,就想起在局域网搭建Maven私服,废话不说了,在测试服务器上建的已经成功,就随便找台机子再练习一遍顺道写个日志。
    1、前往http://www.sonatype.com/download-oss-sonatype下载Nexus-Bundle
      下载地址:http://www.sonatype.org/downloads/nexus-latest-bundle.zip
    2、解压下载的nexus-2.13.0-01-bundle
      
    3、安装并nexus服务
      更改nexus服务端口(可选步骤)
      
      这里使用默认端口 8081
      
    5、修改用户Maven配置文件,%userprofile%.m2setting.xml
      
      Content of setting.xml (You should replace `username`,`password` & `url` in the file if you have changed them.)  

    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                 http://maven.apache.org/xsd/settings-1.0.0.xsd">
      <servers>
        <server>
          <id>releases</id>
          <username>admin</username>
          <password>adminsa</password>
        </server>
        <server>
          <id>snapshots</id>
          <username>admin</username>
          <password>adminsa</password>
        </server>
      </servers>
    
      <mirrors>
        <mirror>
          <id>nexus</id>
          <mirrorOf>*</mirrorOf>
          <url>http://192.168.1.222:7758/nexus/content/groups/public/</url>
        </mirror>
      </mirrors>
    
      <profiles>
        <profile>
          <id>nexus</id>
          <repositories>
            <repository>
              <id>central</id>
              <url>http://central</url>
              <releases><enabled>true</enabled></releases>
              <snapshots><enabled>true</enabled></snapshots>
            </repository>
          </repositories>
    
          <pluginRepositories>
            <pluginRepository>
              <id>central</id>
              <url>http://central</url>
              <releases><enabled>true</enabled></releases>
              <snapshots><enabled>true</enabled></snapshots>
            </pluginRepository>
          </pluginRepositories>
        </profile>
      </profiles>
    
      <activeProfiles>
        <activeProfile>nexus</activeProfile>
      </activeProfiles>
    </settings>

    6、客户端配置(假定已经配置好Maven运行环境)

      为pom.xml添加Maven私服配置
      
      Content of add item

    <repositories>
        <repository>
        <id>nexus</id>
        <name>Team Nexus Repository</name>
        <url>http://127.0.0.1:8081/nexus/content/groups/public</url>
        </repository>
    </repositories>
    
    <pluginRepositories>
        <pluginRepository>
        <id>nexus</id>
        <name>Team Nexus Repository</name>
        <url>http://127.0.0.1:8081/nexus/content/groups/public</url>
        </pluginRepository>
    </pluginRepositories>

    7、客户端测试(需要有Maven项目,没有点击下载 A Simple Maven Project
      进入到Maven项目目录(pom.xml所在目录)
      
    8、验证Maven私服(Repositories -> Repository Path[Central])
      
    9、看到刚刚使用 mvn clean命令下载的plexus-utils-3.0已经在私服仓库中,这时如果局域网内其他机器测试就会直接从私服上下载,为项目构建节省资源。
      可以看到在另一台机器上已经下载一上午的结果(Mac系统有时候让人很无语)
      
      再看看修改了pom.xml后再看看构建是个什么样子吧
      
      构建完成,是不是感觉用起来很爽,值得一提的是,其他客户机上同样需要在用户目录的.m2子目录中创建setting.xml配置上Maven私服。在Intellij Idea上直接 update indecies还不行,明明已经配置了使用下载的Maven,原因正在调查中。
      

  • 相关阅读:
    计算机学习的网站、常用软件
    c语言标识符
    Git报错
    福尔摩斯的约会
    怎样判断一个单链表是否有环?
    中成药的合理使用--风寒感冒
    使用vscode打造python开发环境
    AIDA64 Extreme 6.10.5200 序列号
    VMware Workstation Pro 15密钥及下载地址
    centos 一键安装 Aria2 &管理脚本
  • 原文地址:https://www.cnblogs.com/magics/p/5488989.html
Copyright © 2020-2023  润新知