zoukankan      html  css  js  c++  java
  • maven学习之pom.xml或settings.xml对nexus的配置(转)

    (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中的工厂也不会到中央资源库下载,而是由镜像去下载。这是推荐做法。若镜像下载不到,就下载失败。 

  • 相关阅读:
    开源项目
    [Accessibility] Missing contentDescription attribute on image [可取行]失踪contentDescription属性图像
    Android 布局 中实现适应屏幕大小及组件滚动
    EF 错误记录
    EasyUI 加载时需要显示和隐藏 panel(面板)内容破版问题
    IE 报表缩放后页面破版
    VS 2017 引入nuget 问题
    SSRS 报表显示页面 asp net session丢失或者找不到 asp net session has expired or could not be found()
    log4net 配置
    网站
  • 原文地址:https://www.cnblogs.com/muliu/p/7998685.html
Copyright © 2011-2022 走看看