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:
- 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)- 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:
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)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/se