Maven settings.xml配置(含新阿里云仓库地址)

野性酷女 2023-02-21 06:08 102阅读 0赞

记录一下配置,以免今后重装的时候需要搜索大量的资料。

1. jar包地址自定义:

  1. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  4. <!-- 自定义本地jar包保存地址 -->
  5. <localRepository>D:\Develop\apache-maven-3.6.3\repo</localRepository>

2. jar包镜像地址配置

  1. <mirrors>
  2. <!-- 阿里云旧地址 -->
  3. <mirror>
  4. <!-- id仅是此settings.xml文件中配置mirror的唯一标识 -->
  5. <id>nexus-aliyun</id>
  6. <!-- 指定仓库的类型范围 -->
  7. <mirrorOf>central</mirrorOf>
  8. <!-- 给这个mirror起个名称,类似于说明 -->
  9. <name>nexus-aliyun</name>
  10. <url>http://maven.aliyun.com/nexus/content/groups/public</url>
  11. </mirror>
  12. <!-- 不配置中央仓库的地址也完全可以,因为maven在配置的镜像中搜索不到jar包后,默认会再去中央仓库查找jar包 -->
  13. <!-- 中央仓库1 -->
  14. <mirror>
  15. <id>repo1</id>
  16. <mirrorOf>central</mirrorOf>
  17. <name>Human Readable Name for this Mirror.</name>
  18. <url>http://repo1.maven.org/maven2/</url>
  19. </mirror>
  20. <!-- 中央仓库2 -->
  21. <mirror>
  22. <id>repo2</id>
  23. <mirrorOf>central</mirrorOf>
  24. <name>Human Readable Name for this Mirror.</name>
  25. <url>http://repo2.maven.org/maven2/</url>
  26. </mirror>
  27. </mirrors>

3. 配置JDK版本

  1. <profiles>
  2. <profile>
  3. <id>jdk-1.8</id>
  4. <activation>
  5. <activeByDefault>true</activeByDefault>
  6. <jdk>1.8</jdk>
  7. </activation>
  8. <properties>
  9. <maven.compiler.source>1.8</maven.compiler.source>
  10. <maven.compiler.target>1.8</maven.compiler.target>
  11. <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
  12. </properties>
  13. </profile>
  14. </profiles>

4. 阿里云新镜像地址配置

新阿里云镜像地址
指南不明确

提示的maven配置指南并不明确,在此明确阿里云新镜像地址的配置mirror,希望对大家有所帮助:

  1. <!-- 阿里云新地址之public,central仓和jcenter仓的聚合仓 -->
  2. <mirror>
  3. <id>aliyun-public</id>
  4. <mirrorOf>*</mirrorOf>
  5. <name>aliyun public</name>
  6. <url>https://maven.aliyun.com/repository/public</url>
  7. </mirror>
  8. <!-- 阿里云新地址之central -->
  9. <mirror>
  10. <id>aliyun-central</id>
  11. <mirrorOf>*</mirrorOf>
  12. <name>aliyun central</name>
  13. <url>https://maven.aliyun.com/repository/central</url>
  14. </mirror>

如能帮助到大家甚好,如转载,须注明出处,并附原文链接!
(本文完!)

发表评论

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

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

相关阅读

    相关 Maven配置阿里仓库

    Maven简介: Maven项目[对象模型][Link 1](POM),可以通过一小段描述信息来管理项目的构建,报告和文档的[项目管理工具][Link 2]软件。 Ma