Windows10下maven及IDEA中的配置

下载maven安装包

maven安装包下载地址

在这里插入图片描述
在这里插入图片描述
点击下载后,讲压缩包解压到一个自己熟悉固定的位置。
在这里插入图片描述

maven环境变量的配置

添加M2_HOME:对应Maven的解压目录即可。这里的目录到bin目录的上一级。
在这里插入图片描述
在这里插入图片描述

编辑Path环境变量:
在这里插入图片描述

测试,在cmd窗口输入mvn -v查看,出现如下结果则配置成功。
在这里插入图片描述

修改配置文件

通常我们需要修改的文件是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>D:\Repository</localRepository>

  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

添加国内镜像源
由于maven中央仓库在国外,因此下载速度很慢,换源后下载速度更快
在这里插入图片描述

<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>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
	<mirror>
		<id>alimaven</id>
		<mirrorOf>central</mirrorOf>
		<name>aliyun maven</name>
		<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
	</mirror>
  </mirrors>

还有可以使用的国内仓库。

<!-- 中央仓库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>

修改maven默认的JDK版本
在标签下添加一个标签,修改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>

idea下的maven配置

在这里插入图片描述

!](https://img-blog.csdnimg.cn/20200804200525444.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2RhZmVpZ2V5YQ==,size_16,color_FFFFFF,t_70)

-DarchetypeCatalog=internal

在这里插入图片描述
这样windows下的maven就完全配好了。
最后补充一下Delegate IDE build/run action for maven 这个选项最好也要勾上不然可能会出现一些问题。
IDEA build委托到Maven build – 解决代码没有编译错误运行却报错: "程序包xxx不存在"的问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值