(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. (2):Mysql 查看、创建、更改 数据库和表

    一.一探究竟 我想看看有多少个数据库,有多少个表,以及表里有啥东西.那么你可以这样: 图形界面: 命令: 查看多少个数据库:注意 后面带s #查看 SHOW DATABASES; #查看表 USE b ...

  2. space.php

    天云信息技术有限公司 | 苏ICP备16033617号 1 0.275 ms SELECT * FROM uchome_session WHERE uid='1' Explain id select_ ...

  3. 找回Android studio的帮助文档

    对于业余写点小程序,自娱自乐的我来说,写程序过程的帮助文档非常重要,毕竟不是专业人士.用Visual Studio时,习惯于光标一移到一个类或对象上面,马上出现相应的帮助文档(如图) studio的帮 ...

  4. python接口自动化测试(二)-requests.get()

    环境搭建好后,接下来我们先来了解一下requests的一些简单使用,主要包括: requests常用请求方法使用,包括:get,post requests库中的Session.Cookie的使用 其它 ...

  5. MySQL 支持的数据类型

    1.数值类型 MySQL 支持所有标准 SQL 中的数值类型,其中包括严格数值类型(integer.smallint.decimal.numeric),以及近似数值数据类型(float.real.do ...

  6. Xshell设置密钥登录CentOS6.5_64位(图文版)

    一.环境 CentOS6.5 64位 VMware 14 Pro XSHEEL 5 build 1333 宝塔Linux面板 二.生成XSHELL密钥 三.上传公钥到服务器,并配置 1.上传vCent ...

  7. doctest --- 一个改善python代码质量的工具

    [简介] 说实话吧,之前一直没有怎么重视给自己的代码加上测试逻辑:也就是说我只是写了代码,但是并没有给自己的代码加上测试代码: 整个过程就是写完后自己测试一下,看一下跑出来的结果是正确的就心满意足了. ...

  8. ld: library not found for -lstdc++.6

    ld: library not found for -lstdc++.6 Xcode10 删除 libstdc++.6.tbd libstdc++.6.0.9.tbd 用 libc++.tbd lib ...

  9. go 源码学习之---Tail 源码分析

    已经有两个月没有写博客了,也有好几个月没有看go相关的内容了,由于工作原因最近在做java以及大数据相关的内容,导致最近工作较忙,博客停止了更新,正好想捡起之前go的东西,所以找了一个源码学习 这个也 ...

  10. Mysql Binlog三种格式详细介绍

    一.MySQL Binlog格式介绍 mysql binlog日志有三种格式,分别为Statement,MiXED,以及ROW! 查看binlog的格式的脚本: 二.binlog 的不同模式有什么区别 ...