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

相关推荐
LSL666_1 天前
4 Maven 项目构建与配置要点总结
java·tomcat·maven
e***95641 天前
maven导入spring框架
数据库·spring·maven
g***86691 天前
【mybatis】基本操作:详解Spring通过注解和XML的方式来操作mybatis
xml·spring·mybatis
倚肆1 天前
MyBatis XML 配置详解
xml·java·mybatis
w***4811 天前
Maven Spring框架依赖包
java·spring·maven
GoodStudyAndDayDayUp1 天前
WIN11安装配置验证java\maven
java·开发语言·maven
g***72701 天前
(CICD)自动化构建打包、部署(Jenkins + maven+ gitlab+tomcat)
自动化·jenkins·maven
u***45751 天前
SpringBoot Maven 项目 pom 中的 plugin 插件用法整理
spring boot·后端·maven
q***31891 天前
使用 Logback 的最佳实践:`logback.xml` 与 `logback-spring.xml` 的区别与用法
xml·spring·logback
likuolei2 天前
XML DOM 节点类型
xml·java·服务器