Maven -- setting文件总结

怼烎@ 2022-11-17 11:27 234阅读 0赞

文章目录

      • 前言
        • 先转成中文
        • 指定本机maven依赖下载地址
        • 配置私有仓库账号密码
        • 配置阿里云镜像镜像
        • 配置私有仓库

前言

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


在这里插入图片描述

先转成中文

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

  1. 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依赖下载地址

  1. <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 /密码,因为这些配对是|。一起使用。

  1. <server>
  2. <id>deploymentRepo</id>
  3. <username>repouser</username>
  4. <password>repopwd</password>
  5. </server>

配置私有仓库账号密码

  1. <server>
  2. <id>snapshots</id>
  3. <username>xxxx</username>
  4. <password>xxxx</password>
  5. </server>
  6. <server>
  7. <id>releases</id>
  8. <username>xxxx</username>
  9. <password>xxxx</password>
  10. </server>

mirrors

在这里插入图片描述

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

配置阿里云镜像镜像

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

  1. <mirror>
  2. <id>nexus-aliyun</id>
  3. <mirrorOf>central</mirrorOf>
  4. <name>Nexus aliyun</name>
  5. <url>http://maven.aliyun.com/nexus/content/groups/public</url>
  6. </mirror>

配置私有仓库

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

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

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

  1. <profile>
  2. <id>jdk-1.4</id>
  3. <activation>
  4. <jdk>1.4</jdk>
  5. </activation>
  6. <repositories>
  7. <repository>
  8. <id>jdk14</id>
  9. <name>Repository for JDK 1.4 builds</name>
  10. <url>http://www.myhost.com/maven/jdk14</url>
  11. <layout>default</layout>
  12. <snapshotPolicy>always</snapshotPolicy>
  13. </repository>
  14. </repositories>
  15. </profile>

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

  1. <plugin>
  2. <groupId>org.myco.myplugins</groupId>
  3. <artifactId>myplugin</artifactId>
  4. <configuration>
  5. <tomcatLocation>${tomcatPath}</tomcatLocation>
  6. </configuration>
  7. </plugin>
  8. <profile>
  9. <id>env-dev</id>
  10. <activation>
  11. <property>
  12. <name>target-env</name>
  13. <value>dev</value>
  14. </property>
  15. </activation>
  16. <properties>
  17. <tomcatPath>/path/to/tomcat/instance</tomcatPath>
  18. </properties>
  19. </profile>

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

  1. <profile>
  2. <id>nexus</id>
  3. <repositories>
  4. <repository>
  5. <id>central 中央仓库</id>
  6. <url>nexus 仓库地址</url>
  7. <releases>
  8. <enabled>true</enabled>
  9. </releases>
  10. <snapshots>
  11. <enabled>false</enabled>
  12. </snapshots>
  13. </repository>
  14. <repository>
  15. <id>snapshots 私有仓库地址</id>
  16. <url>私有仓库</url>
  17. <releases>
  18. <enabled>false</enabled>
  19. </releases>
  20. <snapshots>
  21. <enabled>true</enabled>
  22. </snapshots>
  23. </repository>
  24. </repositories>
  25. <pluginRepositories>
  26. <pluginRepository>
  27. <id>central</id>
  28. <url>中央仓库插件</url>
  29. <releases>
  30. <enabled>true</enabled>
  31. </releases>
  32. <snapshots>
  33. <enabled>false</enabled>
  34. </snapshots>
  35. </pluginRepository>
  36. <pluginRepository>
  37. <id>snapshots</id>
  38. <url>私有仓库插件</url>
  39. <releases>
  40. <enabled>false</enabled>
  41. </releases>
  42. <snapshots>
  43. <enabled>true</enabled>
  44. </snapshots>
  45. </pluginRepository>
  46. </pluginRepositories>
  47. </profile>
  48. </profiles>

发表评论

表情:
评论列表 (有 0 条评论,234人围观)

还没有评论,来说两句吧...

相关阅读