Maven -- setting文件总结

前言

真的是醉了,本来想看下maven配置,既然··· 都是要收费的,所以研究一下记录下来


在这里插入图片描述

先转成中文

根据一项或多项贡献者许可协议被许可给Apache Software Foundation(ASF)。有关版权拥有权的其他信息,请参见随本作品分发的NOTICE文件。 ASF根据Apache许可证2.0版(“许可证”)向您授予此文件的许可;除非遵守许可,否则您不得使用此文件。您可以在http://www.apache.org/licenses/LICENSE-2.0上获得许可的副本。除非适用法律要求或以书面形式同意,否则根据“许可”分发的软件均按“原样”分发,没有任何明示或暗示的保证或条件。有关许可下特定的语言管理权限和限制,请参阅许可

http://www.apache.org/licenses/LICENSE-2.0

这是Maven的配置文件。可以在两个级别上指定它:

1.用户级别。此settings.xml文件为单个用户提供配置。并且通常在$ {user.home} /。m2 / settings.xml中提供。
注意:此位置可以使用CLI选项覆盖: -s /path/to/user/settings.xml

2.全球水平。这个settings.xml文件提供了所有Maven的配置。一台计算机上的用户(假设他们都使用相同的Maven 安装)。通常在其中提供$ {maven.conf} /settings.xml。

注意:此位置可以使用CLI选项覆盖:-gs /path/to/global/settings.xml

此样本文件中的各节旨在为您提供一个|的开始。充分利用您的Maven安装。在适当的情况下,默认提供值(未指定设置时使用的值)。

在这里插入图片描述

localRepository 本地存储库maven的路径将用于存储工件。
默认值:$ {user.home} /。m2 / repository / path / to / local / repo

默认就算用户下面有个.m2 下面有个repository 放置maven依赖

所以你可以覆盖重写

指定本机maven依赖下载地址
	<localRepository>D:\depository</localRepository>

指定位置

在这里插入图片描述

InteractiveMode

这将确定maven是否在需要输入时提示您。如果设置为false,则Maven将使用合理的默认值,也许基于其他设置。有问题的参数。
默认值:true true </ interactiveMode>

offline

离线确定执行构建时,maven是否应尝试连接到网络。 这将对工件下载,工件部署等产生影响。默认值:false false </ offline>

pluginGroups

这是通过前缀即解析插件时将搜索的其他组标识符的列表。调用“ mvn prefix:goal”之类的命令行时。 Maven将自动添加组标识符如果“ org.apache.maven.plugins”和“ org.codehaus.mojo”尚未包含在列表中。

servers

指定在连接到特定服务器时要使用的身份验证信息标识。系统内的唯一名称(以下称为“ id”属性)。 注意:您应该指定用户名/密码或privateKey /密码,因为这些配对是|。一起使用。

    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>

配置私有仓库账号密码
	<server>
        <id>snapshots</id>
        <username>xxxx</username>
        <password>xxxx</password>
    </server>
	<server>
      <id>releases</id>
      <username>xxxx</username>
      <password>xxxx</password>
    </server>

mirrors

在这里插入图片描述

指定要使用的存储库镜像站点,而不是给定的存储库。该存储库|此镜像服务的ID与该镜像的mirrorOf元素匹配。使用ID 用于继承和直接查找目的,并且在整个镜像集中必须是唯一的。

配置阿里云镜像镜像

默认是国外的镜像,下载比较慢

<mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
配置私有仓库

在这里插入图片描述
指定要使用一个或多个激活的构建过程的一组介绍。上述机制。出于继承目的,并通过 激活配置文件。或命令行,配置文件必须具有唯一的ID。

鼓励使用的概要文件识别最佳做法是使用一致的命名约定。用于配置文件,例如“ env-dev”,“ env-test”,“ env-production”,“ user-jdcasey”,“ user-brett”等。这将使您更直观地了解这组引入的配置文件正在尝试什么。要完成的任务,特别是当您仅具有用于调试的配置文件ID的列表时。 此概要文件示例使用JDK版本触发激活,并提供了特定于JDK的存储库。

给了一个例子 是 特定的jdk的存储库

<profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>

在这里插入图片描述
这是另一个配置文件,由系统属性“ target-env”激活,值为“ dev”。它提供了到Tomcat实例的特定路径。要使用此功能,您的插件配置可能看起来像:


	<plugin>
 		<groupId>org.myco.myplugins</groupId>
       	<artifactId>myplugin</artifactId>

        <configuration>
             <tomcatLocation>${tomcatPath}</tomcatLocation>
        </configuration>
     </plugin>
	<profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>

注意:如果您只是想在有人将“ target-env”设置为时 那么注入此配置。任何事情,您都可以忽略激活属性中的。

	<profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>central 中央仓库</id>
                    <url>nexus 仓库地址</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>snapshots 私有仓库地址</id>
                    <url>私有仓库</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>中央仓库插件</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
                <pluginRepository>
                    <id>snapshots</id>
                    <url>私有仓库插件</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>	
  </profiles>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值