(1)在POM中配置Nexus仓库

<project>
         ...
         <repositories>
            <repository>
                 <id>nexus</id>
                 <name>Nexus</name>
                <url>http://localhost:8081/nexus/content/groups/public/<url>
                 <release><enabled>true</enabled></release>
                 <snapshots><enabled>true></enabled></snapshots>
             </repository>
        </repositories>
        <pluginRepositories>
             <pluginRepository>
                 <id>nexus</id>
                 <name>Nexus</name>
                <url>http://localhost:8081/nexus/content/groups/public/<url>
                 <release><enabled>true</enabled></release>
                 <snapshots><enabled>true></enabled></snapshots>
              </pluginRepository>
         </pluginRepositories>
         ...
    </project>

上述配置只对当前项目有效,若需让本机所有Maven项目均使用Mavne私服,应该在setting.xml中进行配置。

(2)在setting.xml中配置Nexus仓库

<settings>
          ...
          <profiles>
                <profile>
                    <id>nexus</id>
                    <repositories>
                        <repository>
                          <id>nexus</id>
                          <name>Nexus</name>
                         <url>http://localhost:8081/nexus/content/groups/public/<url>
                          <release><enabled>true</enabled></release>
                          <snapshots><enabled>true></enabled></snapshots>
                        </repository>
                     </repositories>
                     <pluginRepositories>
                        <pluginRepository>
                            <id>nexus</id>
                            <name>Nexus</name>
                          <url>http://localhost:8081/nexus/content/groups/public/<url>
                            <release><enabled>true</enabled></release>
                            <snapshots><enabled>true></enabled></snapshots>
                       </pluginRepository>
                     </pluginRepositories>
                </profile>
           </profiles>
           <activeProfiles>
               <activeProfile>nexus</activeProfiles>
           </activaProfiles>

</settings>

activeProfiles用来激活。

(3) 配置镜像让Maven只使用私服

<settings>
          ...
          <mirrors>
              <mirror>
                  <id>nexus</id>
                  <mirrorOf>*<?mirrorOf>
                 <url>http://localhost:8081/nexus/content/groups/public/</url>
              </mirror>
          </mirrors>
          <profiles>
                <profile>
                    <id>nexus</id>
                    <repositories>
                        <repository>
                          <id>central</id>
                          <name>http://central</name>                       
                          <release><enabled>true</enabled></release>
                          <snapshots><enabled>true></enabled></snapshots>
                        </repository>
                     </repositories>
                     <pluginRepositories>
                        <pluginRepository>
                            <id>central</id>
                            <name>http://central</name>                          
                            <release><enabled>true</enabled></release>
                            <snapshots><enabled>true></enabled></snapshots>
                       </pluginRepository>
                     </pluginRepositories>
                </profile>
           </profiles>
           <activeProfiles>
               <activeProfile>nexus</activeProfiles>
           </activaProfiles>
            ...
    </settings>

只要mirrorOf中的工厂需要下载jar,都会自动来找该镜像。如果镜像地址有,就下载下来。若镜像地址没有,mirrorOf中的工厂也不会到中央资源库下载,而是由镜像去下载。这是推荐做法。若镜像下载不到,就下载失败。

maven学习之pom.xml或settings.xml对nexus的配置(转)的更多相关文章

  1. Maven学习存档(2)——settings.xml配置

    二.settings.xml配置 2.1 原文 <?xml version="1.0" encoding="UTF-8"?> <!-- Lic ...

  2. Maven实战:pom.xml与settings.xml

    pom.xml与settings.xml pom.xml与setting.xml,可以说是Maven中最重要的两个配置文件,决定了Maven的核心功能,虽然之前的文章零零碎碎有提到过pom.xml和s ...

  3. maven的几个重要配置文件pom.xml、settings.xml;Maven打包生成包含所有依赖的jar包

    一个java项目通过maven自动下载依赖时,会涉级读取三个配置文件,分别是项目下的pom.xml 文件 .用户家目录下的.m2/settings.xml 与 maven 全局配置settings.x ...

  4. 【maven学习】pom.xml文件详解

    环境 apache-maven-3.6.1 jdk 1.8 eclipse 4.7 POM是项目对象模型(Project Object Model)的简称,它是Maven项目中的文件,使用XML表示, ...

  5. Maven学习 六 pom.xml文件

    java jar包的搜索网址:http://mvnrepository.com/ pom作为项目对象模型.通过xml表示maven项目,使用pom.xml来实现.主要描述了项目:包括配置文件:开发者需 ...

  6. 解决Maven提示:Could not read settings.xml, assuming default values

    本文转载自:http://blog.csdn.net/hqocshheqing/article/details/47702049 最近在学习Maven  时总是出现 Could not read se ...

  7. 解决Maven提示:Could not read settings.xml

    在Eclipse中配置maven时,提示错误:Could not read settings.xml.用户配置无法生效. 1.首先检查自己的settings.xml配置文件,发现在<!----& ...

  8. Maven入门-3.pom文件和settings文件

    1.pom.xml文件介绍2.settings.xml文件介绍 1.pom.xml文件介绍 Maven项目的核心是pom.xml,pom(Project Object Model项目对象模型) pom ...

  9. maven学习7 settings.xml解析

    maven的配置文件settings.xml存在于两个地方: 1.安装的地方:${M2_HOME}/conf/settings.xml 2.用户的目录:${user.home}/.m2/setting ...

随机推荐

  1. [Functional Programming] Functional JS - Pointfree Logic Functions

    Learning notes. Video. Less than: If you use 'ramda', you maybe know 'lt, gt'.. R.lt(2, 1); //=> ...

  2. exception:Failed to execute 'toDataURL' on 'HTMLCanvasElement' 解决方案

      1.情景展示 当使用canvas 将图片转为base64报错信息如下: Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLC ...

  3. 市场风险~VaR的概述

    1.概念理解 VaR的含义:Value at Risk 按字面的解释就是"处于风险状态的价值",可译为受险价值.在险价值.风险价值等. 通常解释为:VaR是在一定置信水平和一定持有 ...

  4. 基于springboot整合的rabbitmq

    技术:springboot1.5.2 + maven3.0.5 + rabbitmq3.7.13 + jdk1.8   概述 RabbitMQ是对高级消息队列协议(Advanced Message Q ...

  5. 关于VC预定义常量_WIN32,WIN32,_WIN64

    VC2012 下写 Windows 程序时,有时需要判断编译环境.在之前的文章<判断程序是否运行在 Windows x64 系统下.>里说过如何在运行期间判断系统环境,但在编译时如何判断? ...

  6. 关于web项目创建后WEB-INF下面没有出现web.xml的解决方法

    提供两种解决方案: 第一种:创建完项目后,需要手动创建出web.xml 第一步:选取创建的项目名称右击 第二步:eclipse的同学找到 java EE Tools 中的 下图画圈部分.  MyEcl ...

  7. 5款最好的免费在线网站CSS验证器

    这里是一个名单, 5免费在线CSS验证器的网站.这些网站让你验证你的CSS代码的自由,没有任何麻烦.你可以选择上传文件,验证CSS添加URL,或简单的复制和粘贴完整的CSS代码.好的方面是,这些网站不 ...

  8. idea java.lang.OutOfMemoryError: PermGen space

    测试修改 idea  vm.options 无效 , 跟eclipse类似 成功如下 -Xms800m -Xmx800m -XX:MaxNewSize=256m -XX:MaxPermSize=256 ...

  9. 关于VMware Linux 虚拟机忘记root 密码找回

    因为昨天新安装过虚拟机设置了新的密码,再加上我好长时间没有用自己旧的虚拟机,导致忘记了密码,原来虽然知道在单用模式下,找回密码,但是确实是自己从来都没有做过,还好我们组大手飞翔哥告诉了我,怎么找回ro ...

  10. 记录一下idea自动生成Entity

    最近在鼓捣spring -boot ,真好用,学习到jpa. 通过生成Entity 文件,能够快速的生成数据库,并且使用 JpaRepository 的基本增删查改 方法,好用的一批. 可是随之,问题 ...