Maven的安装与配置及碰到的问题(自我总结)

Maven的安装与配置及碰到的问题(自我总结)

Maven下载

首先到官网链接https://maven.apache.org/download.cgi下载.zip压缩包解压
Alt

安装及配置环境

1.选择一个用来安装maven文件的地址(尽量不要是c盘)
2.打开 我的电脑->属性->高级系统设置->环境变量

在系统变量中创建MAVEN_HOME,填入解压后的maven的地址

在系统变量Path中添加maven文件中的bin地址
在这里插入图片描述
打开cmd然后输入mvn -v,然后回车,如图则配置成功

在这里插入图片描述

设置setting.xml

1.在maven文件里创建一个repository文件
2.打开maven的目录文件,打开conf文件,选择setting.xml
2.用Hbuilder或其他文本编辑器打开setting.xml

在这里插入图片描述

先找到/path/to/local/repo,然后复制下去把中间的换成之前创建好的repository地址(注意要换成正斜杠)
在这里插入图片描述
因为服务器在国外,下载jar包很慢,所以改成阿里云服务器的
在这里插入图片描述

<!-- 阿里云仓库 -->
 <mirrors>
	 <mirror>
			<id>nexus-aliyun</id>
			<mirrorOf>*</mirrorOf>
			<name>Nexus aliyun</name>
			<url>http://maven.aliyun.com/nexus/content/groups/public</url>
	</mirror>
</mirrors>

在这里插入图00片描述

<profiles>
<profile>
      <id>jdk-1.8</id>
      <activation>
	    <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>

      <properties>
        <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>
</profiles>

打开cmd输入mvn help:system下载,看到下载链接里面是ailiyun的链接表示配置成功

可能遇到的问题

1.镜像配置问题Error executing Maven.
2.还有就是jdk的问题 ,这个需要打开自己jdk的目录检查(实在不知道哪里有问题重新下就是了,但是要记得安装地址)

碰到第一个镜像配置的问题 ,可能是因为直接复制下来的代码中间有看不见的一些格式问题,将所有空格删除即可。如果还报错,也可以直接copy我的setting.xml文件,但是要记得修改自己的地址。

<?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,
 |            
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值