mac Maven 基础配置和安装

9 篇文章 0 订阅
本文介绍了Maven的核心配置,包括设置本地仓库路径,如改为/Users/mwe/maven/repository,以及配置阿里云的镜像仓库以提高下载速度。此外,还展示了如何在settings.xml中指定JDK1.8版本,并在本地环境变量中配置MAVEN_HOME。最后,通过编辑~/.zshrc文件并执行source命令使配置生效。
摘要由CSDN通过智能技术生成

Maven 核心配置和安装

  • Maven 官网首页

https://maven.apache.org/

  • 下载页面

https://maven.apache.org/download.cgi

在这里插入图片描述

Maven 本地配置

主要关注配置文件中settings
conf/settings.xml
settings.xml 核心配置
  • 指定本地仓库

本地仓库默认值:用户家目录/.m2/repository

  <!-- 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:\maven\repository</localRepository> -->
  <localRepository>/Users/mwe/maven/repository</localRepository>
  • 配置阿里云提供的镜像仓库
  <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>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>
  </mirrors>
  • 配置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>

本地环境变量配置

# 编辑~/.zshrc文件
vim ~/.zshrc



# 添加maven 环境变量
export MAVEN_HOME=/Users/mi/development/maven/apache-maven-3.5.2
export PATH=$PATH:$MAVEN_HOME/bin

# 使配置生效
source ~/.zshrc


mvn -v

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值