当前位置: 首页 > news >正文

配置maven

配置maven

1.下载地址

Download Apache Maven – Maven

2.下载maven压缩包并解压

3.配置系统环境变量

①右键此电脑 → 属性 → 高级系统设置 →环境变量

②在系统变量(不是用户变量)点【新建】

  • 变量名:MAVEN_HOME(大写,不能写错)

  • 变量值:maven 解压根目录,例 D:\DevEnv\apache-maven-3.9.16

    ③在系统变量找到Path,编辑,新建一条:

%MAVEN_HOME%\bin

4.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>标签,加入下面一行(注意不要放到注释乱码):

<localRepository>D:\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 version="1.0" encoding="UTF-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 they're all using the same Maven | installation). It's 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. | |--><settingsxmlns="http://maven.apache.org/SETTINGS/1.2.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd"><!--本地仓库路径,手动提前创建该文件夹--><localRepository>D:\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 <interactiveMode>true</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 <offline>false</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. <pluginGroup>com.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> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</username> <password>proxypass</password> <host>proxy.host.net</host> <port>80</port> <nonProxyHosts>local.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> <id>deploymentRepo</id> <username>repouser</username> <password>repopwd</password> </server> --><!-- Another sample, using keys to authenticate. <server> <id>siteServer</id> <privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave empty if not used.</passphrase> </server> --></servers><mirrors><!--阿里云镜像--><mirror><id>aliyunmaven</id><name>阿里云公共仓库</name><url>https://maven.aliyun.com/repository/public</url><mirrorOf>central</mirrorOf></mirror><!--maven3.9自带http拦截,不要删除--><mirror><id>maven-default-http-blocker</id><mirrorOf>external:http:*</mirrorOf><name>Pseudo repository to mirror external repositories initially using HTTP.</name><url>http://0.0.0.0/</url><blocked>true</blocked></mirror></mirrors><profiles><!--阿里云profile,包含仓库与插件仓库--><profile><id>aliyun</id><repositories><repository><id>aliyun-public</id><url>https://maven.aliyun.com/repository/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>aliyun-plugin</id><url>https://maven.aliyun.com/repository/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories></profile></profiles><!--激活阿里云profile--><activeProfiles><activeProfile>aliyun</activeProfile></activeProfiles></settings>
http://www.jsqmd.com/news/1401813/

相关文章:

  • 2026年8月宁波市移动500M单宽带避坑与办理指南 - 找卡家园
  • Function Calling 挂载AI客服精准查询订单与地址实战
  • 三维内容创作平台MAYA:从节点架构到行业应用的全方位解析
  • 魔域服务器介绍大全:从官服到私服,一文读懂所有选择
  • C/C++开发环境配置:从VSCode到CMake的工程化实践指南
  • 安装deepseek harness及插件
  • 2026年8月山东省泰安市电信单宽带一篇说透怎么选 - 找卡家园
  • 比美替尼仿制药怎么购买?痤疮样皮炎和肌酸磷酸激酶升高怎么管理?
  • 2026年8月山东省临沂市联通单宽带怎么选_避坑指南 - 找卡家园
  • 保定市区企业服务机构拓客技巧 知名AI优化服务商热讯网络
  • AI论文网站最全盘点:从语法校对到查重降AI,一篇就够了
  • AURIX开发环境搭建全攻略:从启动代码到多核调试的实战指南
  • 2026年8月山东省德州市广电单宽带避坑指南一篇说透 - 找卡家园
  • Blender材质贴图入门:从原理到实战,半小时打造真实3D质感
  • 2026年8月山东省泰安市电信单宽带怎么选不踩坑_一篇说透 - 找卡家园
  • 2026年8月山东省临沂市移动单宽带申请避坑全攻略 - 找卡家园
  • 2026年8月四川省自贡市移动单宽带小白避坑办理全攻略 - 找卡家园
  • 泰普瑞合真石漆饰面一体板:精准复刻石材质感 - 品牌排行榜
  • 2026 年更新:九江专业的回收硫酸镍源头厂家哪家专业,那些没人要的电镀废液,藏着你想不到的增收密码? - 企业信息推荐-2
  • 运维转大模型:能写脚本的很多,能搞定权限日志的才稀缺
  • 飞书登录怎么接:Web、桌面客户端、飞书内 H5 与移动端方案对比
  • 2026年8月宁波市移动1000M单宽带小白怎么选宽带 - 找卡家园
  • Turnitin降AI英文按字怎么处理推荐助研君
  • Python Django 登录场景,密码选用哪种加密方案?选型与实战指南
  • 以实战论 AI:诚邀一线工程师分享模型调优、工程落地真实案例
  • 2026年8月山东省日照市电信单宽带办理攻略 - 找卡家园
  • 2026年8月山东省泰安市广电单宽带怎么办理 - 找卡家园
  • 2026年8月宁波市电信1000M单宽带办理避坑实录 - 找卡家园
  • vue和react的响应式有什么区别?(上)
  • 仙桃水下打捞设备|专业潜水打捞队服务怎么联系-鸿腾水下打捞 - 企业推荐管【认证】