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文件中,作为项目私有。

相关推荐
程序员张34 小时前
Maven编译和打包插件
java·spring boot·maven
旷世奇才李先生11 小时前
XML Schema 安装使用教程
xml
代码的余温15 小时前
5种高效解决Maven依赖冲突的方法
java·maven
paishishaba15 小时前
Maven
java·maven
ddfa12341 天前
XML 笔记
xml·服务器
代码的余温1 天前
Maven引入第三方JAR包实战指南
java·maven·jar
Wyc724092 天前
Maven
java·数据库·maven
一勺菠萝丶2 天前
Spring Boot + MyBatis/MyBatis Plus:XML中循环处理List参数的终极指南
xml·spring boot·mybatis
逆风局?2 天前
Maven高级——分模块设计与开发
java·maven
周某某~2 天前
maven详解
java·maven