settings.xml的文件配置大全

settings.xml 文件中最常配置的还是这几个标签
localRepositorymirrors

settings.xml文件官方文档地址

xml 复制代码
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  
    <!-- 本地仓库的路径 -->
    <localRepository>${user.home}/.m2/repository</localRepository>
    <!-- 是否时交互式,默认式true
    当用户可能需要为 Maven 提供额外的输入或作出决策时,interactiveMode被设置为true是非常有用的
    当用在ci\cd功能中时,则不希望有这种需要交互的程序,此时需要设置成false -->
    <interactiveMode>true</interactiveMode>
    <!-- 是否应用离线模式,默认false -->
    <offline>false</offline>
    
    <!-- 当你在命令行中使用插件时,可以省略该插件的 groupId。例如,mvn compiler:compile 会默认为 
org.apache.maven.plugins 的 groupId,因此你不需要指定完整的 groupId,如 mvn org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile。 -->
  	<pluginGroups>
    	<pluginGroup>org.apache.maven.plugins</pluginGroup>
	</pluginGroups>
	
    <!-- 用于身份的验证,该内容需要和项目中的pom.xml的distributionManagement的id匹配 -->
    <servers>
        <server>
            <id>my-remote-repository</id>
            <username>admin</username>
            <password>password123</password>
        </server>
    </servers>
    
    <!-- 中央仓库的镜像仓库地址配置 -->
  	<mirrors>
      <mirror> 
            <id>alimaven</id>  
            <name>aliyun maven</name>  
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
            <mirrorOf>central</mirrorOf> 
      </mirror>
  	</mirrors>
  	
    <!-- 当你运行 Maven 构建并且 Maven 需要从远程仓库检索依赖项或插件时,Maven 会使用这些代理设置来访问互联网。通过配置代理,你可以确保 Maven 请求走过你的代理服务器。 -->
  	<proxies>
       <proxy>
          <id>example-proxy</id>
          <active>true</active>
          <protocol>http</protocol>
          <host>proxy.example.com</host>
          <port>8080</port>
          <username>proxyuser</username>
          <password>somepassword</password>
          <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
       </proxy>
    </proxies>
    
	<!-- profiles 标签用于定义特定于环境或情境的构建配置。这意味着,基于某些条件(例如系统属性、环境变量或文件存在性),你可以更改 Maven 构建的行为。它允许开发者在不更改主要的 POM 配置的情况下,为特定的环境或目的定制构建。 -->
    <profiles>
        <profile>
            <id>windows-profile</id>
            <activation>
                <os>
                    <family>Windows</family>
                </os>
            </activation>
            <properties>
                <path.separator>\</path.separator>
            </properties>
        </profile>

        <profile>
            <id>unix-profile</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <path.separator>/</path.separator>
            </properties>
        </profile>
    </profiles>
    <!-- activeProfiles 标签被用来指定默认情况下需要被激活的 profiles。 -->
    <activeProfiles>
       <activeProfile>dev-profile</activeProfile>
    </activeProfiles>
</settings>

nexus 私服信息一般时配置到pom.xml文件中,作为项目私有。

相关推荐
l1t14 小时前
利用美团龙猫用libxml2编写XML转CSV文件C程序
xml·c语言·libxml2·解析器
ZZHow10241 天前
Maven入门_简介、安装与配置
java·笔记·maven
yunmi_1 天前
2024版 IDEA 用 Maven 创建 java 项目(+Maven 安装和配置)
java·maven
煎饼皮皮侠2 天前
【图解】idea中快速查找maven冲突
java·maven·intellij-idea·冲突
麦兜*2 天前
MongoDB 与 GraphQL 结合:现代 API 开发新范式
java·数据库·spring boot·mongodb·spring·maven·graphql
叶 落2 天前
[Maven 基础课程]第一个 Maven 项目
maven·maven 入门·maven 基础
码畜也有梦想3 天前
Maven中optional的作用
java·jenkins·maven
Luna-player4 天前
某个工程 pom.xml
xml
l1t4 天前
对expat库XML_Parse函数调用优化的测试
xml·c语言·解析器·expat