windows安装maven

一、去官网下载一个maven

http://maven.apache.org/download.cgi
这里需要主要一下版本问题,来这里看http://maven.apache.org/docs/history.html
我这里是java8,装这个3.6.0没问题,这里的required说的是需要的版本要在其说明的之上才可以。选择这个release notes
在这里插入图片描述
跳转之后选这个
在这里插入图片描述
选择这个bin.zip后缀的下载
在这里插入图片描述
下载之后解压缩

二、配置windows环境变量

右键计算机-》属性,然后选择高级系统设置
在这里插入图片描述
然后选择高级-》环境变量
在这里插入图片描述
配置两个变量,选择新建
在这里插入图片描述
第一个写这个,(个人觉得安装目录还是不放中文比较好,也别整什么空格啥的不然容易出事,我这个是不太好的示范)
M2_HOME
E:\java工具\maven\apache-maven-3.6.0
在这里插入图片描述
MAVEN_HOME
E:\java工具\maven\apache-maven-3.6.0
在这里插入图片描述
双击这个
在这里插入图片描述
里面加入这个,这里的;是分隔各个不同的软件的,%xx%这是一个指代,指代我们前面写的地址
;%M2_HOME%\bin;
在这里插入图片描述
最后全部确认结束就好了

三、测试是否安装成功

cmd进入之后输入

mvn -version

在这里插入图片描述

四、修改一下镜像仓库以及本地的maven仓库地址

去到之前解压的文件夹位置然后进去里面的conf文件夹,(我这里是E:\java工具\maven\apache-maven-3.6.0\conf),然后打开settings.xml
在这里插入图片描述
修改里面的本地仓库位置

<!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
	 <localRepository>/path/to/local/repo</localRepository>
  -->
  <localRepository>E:/java工具/maven/apache-maven-3.6.0/localrepo</localRepository>

在这里插入图片描述

配置镜像仓库,这里是阿里云加速仓库,加了会好很多,起码以后你下载jar包会变得快多了

<mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
  
     -->
		<mirror>
			<id>nexus-aliyun</id>
			<mirrorOf>*</mirrorOf>
			<name>Nexus aliyun</name>
			<url>http://maven.aliyun.com/nexus/content/groups/public</url>
		</mirror> 
  </mirrors>

在这里插入图片描述
配置默认的java版本,这是在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>

在这里插入图片描述
上面如果不配置的话,那你要在maven项目的pom.xml就要加入这个设置java版本。但是推荐还是直接在上面配置文件中修改。

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

我这里说明一下为什么要加呢?因为我新建maven项目后发现如果不加默认使用的是java1.5。如果在settings.xml里面设定了版本,那么以后项目就可以写少几行,但是如果你需要用到的几个项目java版本不一样,那么就在项目的pom.xml里面加吧

我上面那里配置就差不多了,这里有个maven配置仓库的处理,这个写的还可以
https://blog.csdn.net/qq_35720307/article/details/87088388

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值