配置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(配置时会用到,别解压完就找不到了哦)
配置Apache Maven 3.6.1_第1张图片

配置环境变量

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

2.配置

在maven安装目录的conf里面有一个settings.xml文件,这个文件就是maven的全局配置文件。
配置Apache Maven 3.6.1_第7张图片

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

完整的settings.xml:






<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  

  

  

  
  <pluginGroups>
    
  pluginGroups>

  
  <proxies>
    
  proxies>

  
  <servers>
    

    
  servers>

  
  <mirrors>
    
	 
	<mirror>  
    <id>nexus-aliyunid>  
    <mirrorOf>centralmirrorOf>    
    <name>Nexus aliyunname>  
    <url>http://maven.aliyun.com/nexus/content/groups/publicurl>  
	mirror>
  mirrors>

  
   
  <profiles>
  <profile>
            <id>jdk-1.8id>
            <activation>
                <jdk>1.8jdk>
            activation>
            <repositories>
                <repository>
                    <id>nexusid>
                    <name>local private nexusname>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/url>
                    <releases>
                        <enabled>trueenabled>
                    releases>
                    <snapshots>
                        <enabled>falseenabled>
                    snapshots>
                repository>
            repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>nexusid>
                    <name>local private nexusname>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/url>
                    <releases>
                        <enabled>trueenabled>
                    releases>
                    <snapshots>
                        <enabled>falseenabled>
                    snapshots>
                pluginRepository>
            pluginRepositories>
        profile>
    

    
  profiles>

  
settings>

IDEA中配置Maven
在这里插入图片描述
在这里插入图片描述

你可能感兴趣的:(Spring,Boot)