配置Apache Maven 3.6.1

1.安装

当我们要使用某个工具的时候,大家首先想到的肯定是去官网download对吧?很好!
今天刚开始学习Spring Boot,要用到Apache Maven,二话不说先百度Apache Maven,成功进入到官网download页面点我呀~~

只找到3.6.2版本,所以就下了,接着就解压配置…到后面终于还是挂了
报错:

2019-09-20 21:38:56,305 [ 351757] ERROR - #org.jetbrains.idea.maven - com.google.inject.CreationException: Unable to create injector, see the following errors:

  1. No implementation for org.apache.maven.model.path.PathTranslator was bound.
    while locating org.apache.maven.model.path.PathTranslator
    for field at org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator.pathTranslator(Unknown Source)
    at org.codehaus.plexus.DefaultPlexusContainer$1.configure(DefaultPlexusContainer.java:350)
  2. No implementation for org.apache.maven.model.path.UrlNormalizer was bound.
    while locating org.apache.maven.model.path.UrlNormalizer
    for field at org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator.urlNormalizer(Unknown Source)
    at org.codehaus.plexus.DefaultPlexusContainer$1.configure(DefaultPlexusContainer.java:350)

2 errors
java.lang.RuntimeException: com.google.inject.CreationException: Unable to create injector, see the following errors:

  1. No implementation for org.apache.maven.model.path.PathTranslator was bound.
    while locating org.apache.maven.model.path.PathTranslator
    for field at org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator.pathTranslator(Unknown Source)
    at org.codehaus.plexus.DefaultPlexusContainer$1.configure(DefaultPlexusContainer.java:350)

  2. No implementation for org.apache.maven.model.path.UrlNormalizer was bound.
    while locating org.apache.maven.model.path.UrlNormalizer
    for field at org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator.urlNormalizer(Unknown Source)
    at org.codehaus.plexus.DefaultPlexusContainer$1.configure(DefaultPlexusContainer.java:350)

此处省略若干行。。。

有意思,这不是最新版吗?(说明并不是版本越新越好用!!!)搞不清楚到底是配置出问题了,还是不兼容,感觉应该是不兼容

所以开始入手3.6.1版本(推荐使用)

  • 方式一:

链接:https://pan.baidu.com/s/1Mc30h8NEiUN-6QNLFg7jCg
提取码:bt3h

  • 方式二:
    https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/

下载好安装包(此处用的是方式一中的安装包),在自己电脑里边选个位置给它解压了(最好别放C盘!!!),我这里解压的目录为:
D:\Tools\apache-maven-3.6.1(配置时会用到,别解压完就找不到了哦)
在这里插入图片描述

配置环境变量

步骤:
1.右击计算机或此电脑——>点击“属性”
在这里插入图片描述
2.进入到“控制面板\所有控制面板板项\系统”界面,点击“高级系统设置”
在这里插入图片描述
3.进入到“系统属性”界面,点击“环境变量配置”
在这里插入图片描述
4.新建一个变量,变量名:M2_HOME 变量值:D:\Tools\apache-maven-3.6.1(Maven存放在本地的目录)
编辑变量PATH,在原有的变量值后面加上%M2_HOME%\bin;
在这里插入图片描述
测试是否安装成功
打开cmd,执行mvn -v命令,显示如下:(至此,表明Maven安装成功)
在这里插入图片描述

2.配置

在maven安装目录的conf里面有一个settings.xml文件,这个文件就是maven的全局配置文件。
在这里插入图片描述

  • 注意:所有的修改一定要在注释标签外面,不然修改无效。Maven很多标签都是给的例子,都是注释掉的。

完整的settings.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,
 |                 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 t
评论 27
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值