(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. 自动化web前端测试,自动登录网站.目前发现最靠谱的方法是imacros

    imacros免费版 登录宏代码的示例: //首先登出URL GOTO=http://yoursite/logout.html//打开登录页面URL GOTO=http://yoursite/logi ...

  2. asp.net mvc 实战化项目之三板斧

    laravel实战化项目之三板斧 spring mvc 实战化项目之三板斧 asp.net mvc 实战化项目之三板斧 接上文希望从一张表(tb_role_info 用户角色表)的CRUD展开asp. ...

  3. t-SNE 层次聚类

    https://zhuanlan.zhihu.com/p/28967965 https://haojunsui.github.io/2016/07/16/scipy-hac/

  4. Gitlab团队协作流程

    一:加入群组 项目管理员添加用户到群组,赋予权限(owner.developer...). 二:拉取项目,建立分支 通过git clone拉取项目到本地,通过终端打开项目目录,创建自己的分支,并推送到 ...

  5. 【PHP】解析PHP中的变量

    php是一门脚本语言,同时php中的变量类型也是弱语言类型,这和javascript非常相似.笔者在这里说一说PHP中的变量知识点. 1. 引用类型变量 看下面的案例: <?php class ...

  6. 城市经纬度 json 理解SignalR Main(string[] args)之args传递的几种方式 串口编程之端口 多线程详细介绍 递归一个List<T>,可自己根据需要改造为通用型。 Sql 优化解决方案

    城市经纬度 json https://www.cnblogs.com/innershare/p/10723968.html 理解SignalR ASP .NET SignalR 是一个ASP .NET ...

  7. Android Studio打包过程和应用安装过程

    三个部分,检查项目和读取基本配置,Gradle Build,Apk Install和LaunchActivity. 应用安装到手机,会复制APK安装包到data/app目录下,解压并扫描安装包,把de ...

  8. [转]Anatomy of a Program in Memory

    Memory management is the heart of operating systems; it is crucial for both programming and system a ...

  9. SNF软件开发机器人-子系统-功能-数据列表分页与不分页-瀑布式分页-如何配置?

    [列表]分页 1.效果展示: (1)不分页 (2)普通分页 (3)瀑布式分页 2.使用说明: 打开显示页面,点击开发者选项的简单配置按钮.在功能表信息中选择需要的分页方式.普通分页和瀑布式分页需要配合 ...

  10. 性能测试相关(TPS/RT/PV等)(转)

    对于我们开发来说,我们日常最熟悉的工作就是把客户的需求实现并交付.但是,事情并不是往往就这样结束了,我们还需要后续对上线的系统进行跟踪调查,查看系统的运行情况.为什么呢?一方面,我们需要关注系统在运行 ...