【setting.xml文件】配置

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <!-- Apache Maven 配置 -->
    <pluginGroups/>
    <proxies/>
    
    <!-- 阿里云镜像 -->
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <!-- https://maven.aliyun.com/repository/public/ -->
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>

    <!-- 配置: java8, 先从阿里云下载, 没有再去私服下载  -->
    <!-- 20190929 hepengju 测试结果: 影响下载顺序的是profiles标签的配置顺序(后面配置的ali仓库先下载), 而不是activeProfiles的顺序 -->
    <profiles>
        <!-- 全局JDK1.8配置 -->
        <profile>
            <id>jdk1.8</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
        <!-- 阿里云配置: 提高国内的jar包下载速度 -->
        <profile>
            <id>ali</id>
            <repositories>
                <repository>
                    <id>alimaven</id>
                    <name>aliyun maven</name>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>alimaven</id>
                    <name>aliyun maven</name>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>

    </profiles>
    
    <!-- 激活配置 --> 
    <activeProfiles>
        <activeProfile>jdk1.8</activeProfile>
        <activeProfile>dev</activeProfile>
        <activeProfile>ali</activeProfile>
    </activeProfiles>
</settings>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Maven是一款Java项目管理工具,而setting.xmlMaven配置文件之一,它位于Maven安装目录下的conf文件夹中,用于配置Maven的全局设置、仓库、代理服务器等信息,以及用户自定义的配置信息。下面是setting.xml文件的详细配置介绍: 1. 服务器设置 ``` <servers> <server> <id>server1</id> <username>user1</username> <password>pwd1</password> </server> </servers> ``` 这里定义了一个名为server1的服务器,指定了用户名和密码。 2. 代理服务器设置 ``` <proxies> <proxy> <id>proxy1</id> <active>true</active> <protocol>http</protocol> <host>proxy.example.com</host> <port>8080</port> <username>user1</username> <password>pwd1</password> <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts> </proxy> </proxies> ``` 这里定义了一个名为proxy1的代理服务器,指定了代理服务器的地址、端口、用户名和密码等信息。 3. 仓库设置 ``` <repositories> <repository> <id>central</id> <url>http://central.maven.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> ``` 这里定义了一个名为central的仓库,指定了仓库的地址、是否启用发布版本和快照版本等信息。 4. 插件仓库设置 ``` <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central.maven.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> ``` 这里定义了一个名为central的插件仓库,指定了仓库的地址、是否启用发布版本和快照版本等信息。 5. 全局设置 ``` <settings> <offline>false</offline> <interactiveMode>true</interactiveMode> <usePluginRegistry>true</usePluginRegistry> <offlineCache> <enabled>false</enabled> </offlineCache> <mirrors> <mirror> <id>mirror1</id> <name>mirror1</name> <url>http://mirror1.example.com</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors> <profiles> <profile> <id>profile1</id> <repositories> <repository> <id>central</id> <url>http://central.maven.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central.maven.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>profile1</activeProfile> </activeProfiles> </settings> ``` 这里定义了Maven的全局配置信息,包括是否离线模式、是否交互式模式、是否使用插件注册表等。 以上为setting.xml文件的详细配置介绍,通过配置setting.xml文件,可以更好地控制Maven的行为。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值