ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

配置maven

2026/8/16 2:14:06 拓冰建站 浏览量
配置maven 配置maven1.下载地址Download Apache Maven – Maven2.下载maven压缩包并解压3.配置系统环境变量①右键此电脑 → 属性 → 高级系统设置 →环境变量②在系统变量不是用户变量点【新建】变量名MAVEN_HOME大写不能写错变量值maven 解压根目录例 D:\DevEnv\apache-maven-3.9.16③在系统变量找到Path编辑新建一条%MAVEN_HOME%\bin4.cmd mvn -v验证是否成功5.修改 settings.xml最重要本地仓库 阿里云镜像解决下载慢文件位置maven解压目录/conf/settings.xml用记事本 / VSCode 打开ps提前手动新建文件夹D:\DevEnv\apache-maven-3.9.16\Repository①设置本地仓库不占用 C 盘先在 D 盘新建文件夹例如D:\maven_repo用来存放下载的 jar 包。找到settings标签加入下面一行注意不要放到注释乱码localRepositoryD:\DevEnv\apache-maven-3.9.16\Repository/localRepository②添加阿里云镜像国内下载依赖飞快找到文件里的mirrors/mirrors标签把下面 mirror 复制粘贴进去aliyunmaven 阿里云公共仓库 https://maven.aliyun.com/repository/public central ![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/1ff9d01d4e4c4b88ab5197bd64e41b47.png)6.完整版?xml version1.0 encodingUTF-8?!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --!-- | This is the configuration file for Maven. It can be specified at two levels: | | 1. User Level. This settings.xml file provides configuration for a single user, | and is normally provided in ${user.home}/.m2/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml | | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming theyre all using the same Maven | installation). Its normally provided in | ${maven.conf}/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | |--settingsxmlnshttp://maven.apache.org/SETTINGS/1.2.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd!--本地仓库路径手动提前创建该文件夹--localRepositoryD:\DevEnv\apache-maven-3.9.16\Repository/localRepository!-- interactiveMode | This will determine whether maven prompts you when it needs input. If set to false, | maven will use a sensible default value, perhaps based on some other setting, for | the parameter in question. | | Default: true interactiveModetrue/interactiveMode --!-- offline | Determines whether maven should attempt to connect to the network when executing a build. | This will have an effect on artifact downloads, artifact deployment, and others. | | Default: false offlinefalse/offline --!-- pluginGroups | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e. | when invoking a command line like mvn prefix:goal. Maven will automatically add the group identifiers | org.apache.maven.plugins and org.codehaus.mojo if these are not already contained in the list. |--pluginGroups!-- pluginGroup | Specifies a further group identifier to use for plugin lookup. pluginGroupcom.your.plugins/pluginGroup --/pluginGroups!-- proxies | This is a list of proxies which can be used on this machine to connect to the network. | Unless otherwise specified (by system property or command-line switch), the first proxy | specification in this list marked as active will be used. |--proxies!-- proxy | Specification for one proxy, to be used in connecting to the network. | proxy idoptional/id activetrue/active protocolhttp/protocol usernameproxyuser/username passwordproxypass/password hostproxy.host.net/host port80/port nonProxyHostslocal.net|some.host.com/nonProxyHosts /proxy --/proxies!-- servers | This is a list of authentication profiles, keyed by the server-id used within the system. | Authentication profiles can be used whenever maven must make a connection to a remote server. |--servers!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the id attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. | server iddeploymentRepo/id usernamerepouser/username passwordrepopwd/password /server --!-- Another sample, using keys to authenticate. server idsiteServer/id privateKey/path/to/private/key/privateKey passphraseoptional; leave empty if not used./passphrase /server --/serversmirrors!--阿里云镜像--mirroridaliyunmaven/idname阿里云公共仓库/nameurlhttps://maven.aliyun.com/repository/public/urlmirrorOfcentral/mirrorOf/mirror!--maven3.9自带http拦截不要删除--mirroridmaven-default-http-blocker/idmirrorOfexternal:http:*/mirrorOfnamePseudo repository to mirror external repositories initially using HTTP./nameurlhttp://0.0.0.0//urlblockedtrue/blocked/mirror/mirrorsprofiles!--阿里云profile包含仓库与插件仓库--profileidaliyun/idrepositoriesrepositoryidaliyun-public/idurlhttps://maven.aliyun.com/repository/public/urlreleasesenabledtrue/enabled/releasessnapshotsenabledtrue/enabled/snapshots/repository/repositoriespluginRepositoriespluginRepositoryidaliyun-plugin/idurlhttps://maven.aliyun.com/repository/public/urlreleasesenabledtrue/enabled/releasessnapshotsenabledtrue/enabled/snapshots/pluginRepository/pluginRepositories/profile/profiles!--激活阿里云profile--activeProfilesactiveProfilealiyun/activeProfile/activeProfiles/settings