Maven安装+环境变量配置+setting.xml基本配置

  1. 安装Maven
    官网下载地址:https://maven.apache.org/download.cgi
    下载完解压放到自己想要的目录下
  2. 设置环境变量
    M2_HOME: 路径为Maven安装目录
    PATH: %M2_HOME%\bin
    在这里插入图片描述

在这里插入图片描述

  1. 测试Maven是否安装成功
    打开cmd,输入 mvn --versionmvn -v,出现以下界面则环境变量设置成功
    在这里插入图片描述
    如果提示识别不了mvn命令,检查M2_HOME和PATh配置是否配置好,如果都配置好了还是识别不了mvn命令,重启电脑

  2. 配置setting.xml
    在conf目录下修改setting.xml
    在这里插入图片描述

    4.1 修改Maven本地仓库

    <localRepository>D:\Software\apache-maven-3.8.3\local\repo</localRepository>
    

    4.2 修改Maven默认JDK版本

    <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>
    

    4.3 添加国内Maven镜像仓库

    <!-- 阿里云仓库 -->
    <mirror>
        <id>alimaven</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>
    
    <!-- 中央仓库1 -->
    <mirror>
        <id>repo1</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://repo1.maven.org/maven2/</url>
    </mirror>
    
    <!-- 中央仓库2 -->
    <mirror>
        <id>repo2</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://repo2.maven.org/maven2/</url>
    </mirror>
    
  3. IDE下配置Maven
    在这里插入图片描述
    在这里插入图片描述
    附setting.xml配置

    <?xml version="1.0" encoding="UTF-8"?>
    
    <settings xmlns="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:\Software\apache-maven-3.8.3\local\repo</localRepository>
    
      <pluginGroups>
    
      </pluginGroups>
    
    
      <proxies>
    
      </proxies>
    
    
      <servers>
    
      </servers>
    
      <mirrors>
        <!-- 阿里云仓库 -->
    	<mirror>
    		<id>alimaven</id>
    		<mirrorOf>central</mirrorOf>
    		<name>aliyun maven</name>
    		<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    	</mirror>
    	
    	<!-- 中央仓库1 -->
    	<mirror>
    	    <id>repo1</id>
    	    <mirrorOf>central</mirrorOf>
    	    <name>Human Readable Name for this Mirror.</name>
    	    <url>http://repo1.maven.org/maven2/</url>
    	</mirror>
    	
    	<!-- 中央仓库2 -->
    	<mirror>
    	    <id>repo2</id>
    	    <mirrorOf>central</mirrorOf>
    	    <name>Human Readable Name for this Mirror.</name>
    	    <url>http://repo2.maven.org/maven2/</url>
    	</mirror>
      </mirrors>
    
      <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>
    </settings>
    
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值