zoukankan      html  css  js  c++  java
  • 使用Nexus管理maven仓库,setting文件理解

    来到新公司对很多陌生的技术一头雾水,以前在工作中没有真正使用过maven,于是强迫自己蛋定下来一个一个的突破,下面是我对maven的setting配置文件的理解,由于是现学的,难免可能会理解偏差,还请牛人路过指正。

    Xml代码  收藏代码
    1. <!--  
    2. xuze added by:添加了一些注释,利于新人理解  
    3. Date:2011年7月18日  
    4. -->  
    5. <settings>  
    6.   <!-- 配置镜像 -->  
    7.   <mirrors>     
    8.     <mirror>  
    9.       <!-- 此镜像一般用来作为公司内部开发的版本快照,作为public-snapshots仓库的镜像地址 -->  
    10.       <!-- 镜像的id,id用来区分不同的mirror元素。 -->   
    11.       <id>nexus-public-snapshots</id>  
    12.       <!-- 被镜像的服务器的id。例如,如果我们要设置了一个Maven中央仓库(http://repo1.maven.org/maven2)的镜像,  
    13.         就需要将该元素设置成central。这必须和中央仓库的id “central”完全一致。 -->  
    14.       <mirrorOf>public-snapshots</mirrorOf>  
    15.       <!-- 该镜像的URL。 -->   
    16.       <url>http://repos.d.xxx.com/nexus/content/groups/public-snapshots</url>  
    17.     </mirror>  
    18.       
    19.     <mirror>  
    20.       <!-- 此镜像一般用来作为公司第三方引用基础类库镜像,是所有仓库的镜像地址 -->  
    21.       <id>nexus</id>  
    22.       <!-- 为*表示为所有的仓库做镜像,有了这个配置,所有的构建都会包含public组,如果你想包含public-snapshots组,  
    23.         你必须添加public-snapshots这个Profile,通过在命令行使用如下的 -P 标志:$ mvn -P public-snapshots clean install -->  
    24.       <mirrorOf>*</mirrorOf>  
    25.       <url>http://repos.d.xxx.com/nexus/content/groups/public</url>  
    26.     </mirror>   
    27.   </mirrors>  
    28.     
    29.   <!-- settings.xml中的profile元素是pom.xml中profile元素的裁剪版本。它包含了activation, repositories, pluginRepositories 和 properties元素。  
    30.     这里的profile元素只包含这四个子元素是因为这里只关心构建系统这个整体(这正是settings.xml文件的角色定位),而非单独的项目对象模型设置。    
    31.     如果一个settings中的profile被激活,它的值会覆盖任何其它定义在POM中或者profile.xml中的带有相同id的profile。 -->   
    32.   <profiles>  
    33.     <profile>  
    34.       <id>development</id>  
    35.       <!-- 仓库。仓库是Maven用来填充构建系统本地仓库所使用的一组远程项目。而Maven是从本地仓库中使用其插件和依赖。  
    36.         不同的远程仓库可能含有不同的项目,而在某个激活的profile下,可能定义了一些仓库来搜索需要的发布版或快照版构件。有了Nexus,这些应该交由Nexus完成 -->  
    37.       <repositories>  
    38.         <repository>  
    39.           <id>central</id>  
    40.           <!-- 虚拟的URL形式,指向镜像的URL,因为所有的镜像都是用的是nexus,这里的central实际上指向的是http://repos.d.xxx.com/nexus/content/groups/public -->  
    41.           <url>http://central</url>  
    42.           <!-- 表示可以从这个仓库下载releases版本的构件-->  
    43.           <releases><enabled>true</enabled></releases>  
    44.           <!-- 表示可以从这个仓库下载snapshot版本的构件 -->  
    45.           <snapshots><enabled>true</enabled></snapshots>  
    46.         </repository>  
    47.       </repositories>  
    48.        
    49.      <!-- 插件仓库。仓库是两种主要构件的家。第一种构件被用作其它构件的依赖。这是中央仓库中存储大部分构件类型。  
    50.         另外一种构件类型是插件。Maven插件是一种特殊类型的构件。由于这个原因,插件仓库独立于其它仓库。  
    51.         pluginRepositories元素的结构和repositories元素的结构类似。每个pluginRepository元素指定一个Maven可以用来寻找新插件的远程地址。 -->    
    52.      <pluginRepositories>  
    53.         <pluginRepository>  
    54.           <id>central</id>  
    55.           <url>http://central</url>  
    56.           <releases><enabled>true</enabled></releases>  
    57.           <snapshots><enabled>true</enabled></snapshots>  
    58.         </pluginRepository>  
    59.       </pluginRepositories>  
    60.     </profile>  
    61.       
    62.     <profile>  
    63.       <!--this profile will allow snapshots to be searched when activated-->  
    64.       <id>public-snapshots</id>  
    65.       <repositories>  
    66.         <repository>  
    67.           <id>public-snapshots</id>  
    68.           <!-- 虚拟的URL形式,指向镜像的URL,这里指向的是http://repos.d.xxx.com/nexus/content/groups/public-snapshots -->  
    69.           <url>http://public-snapshots</url>  
    70.           <releases><enabled>false</enabled></releases>  
    71.           <snapshots><enabled>true</enabled></snapshots>  
    72.         </repository>  
    73.       </repositories>  
    74.      <pluginRepositories>  
    75.         <pluginRepository>  
    76.           <id>public-snapshots</id>  
    77.           <url>http://public-snapshots</url>  
    78.           <releases><enabled>false</enabled></releases>  
    79.           <snapshots><enabled>true</enabled></snapshots>  
    80.         </pluginRepository>  
    81.       </pluginRepositories>  
    82.     </profile>  
    83.   </profiles>  
    84.     
    85.   <!-- 激活的Profile。activation元素并不是激活profile的唯一方式。settings.xml文件中的activeProfile元素可以包含profile的id,  
    86.     任何在activeProfile中定义的profile id,不论环境设置如何,其对应的profile都会被激活。如果没有匹配的profile,则什么都不会发生。  
    87.     profile也可以通过在命令行,使用-P标记和逗号分隔的列表来显式的激活(如,-P test)。  
    88.     要了解在某个特定的构建中哪些profile会激活,可以使用maven-help-plugin(mvn help:active-profiles)。 -->    
    89.   <activeProfiles>  
    90.     <!-- 没有显示激活public-snapshots -->  
    91.     <activeProfile>development</activeProfile>  
    92.   </activeProfiles>  
    93.   
    94. <!-- 自定义本地仓库地址,其默认值为~/.m2/repository -->  
    95. <localRepository>/data/maven-repository</localRepository>  
    96.   
    97.   <!-- 发布的服务器和密码,暂时未限制权限 -->  
    98.    <servers>  
    99.     <server>  
    100.       <!-- 发布的位置在POM中配置,以ID为关联,有很多公用的信息需要配置在POM文件里,最佳实践是定义一个公司级别的root pom -->  
    101.       <id>archiva.internal</id>  
    102.       <username>maven</username>  
    103.       <password>1q2w3e4r</password>  
    104.     </server>  
    105.     <server>  
    106.       <id>archiva.snapshots</id>  
    107.       <username>maven</username>  
    108.       <password>1q2w3e4r</password>  
    109.     </server>  
    110.   </servers>  
    111. </settings>  
  • 相关阅读:
    tp5中调用接口api中的数据
    TP5.0如何转换成SQL语句输出构造器里面的方法
    unlink() 函数删除文件。
    tp5 图片上传
    Java第十一章多线程
    Java Character类
    前端技术学习路线及技术汇总
    Web发展史
    HTML
    JavaNumber类&JavaMath类
  • 原文地址:https://www.cnblogs.com/adolfmc/p/5069569.html
Copyright © 2011-2022 走看看