Maven开发环境搭建
下载安装
打开官网:下载地址,
在Previous Releases
处点击archives
进入版本下载页面。
配置环境变量
下载并解压,配置环境变量新增M2_HOME
,并修改Path
,cmd
窗口执行mvn -v
看到maven的当前版本即配置成功。
修改setting.xml-修改为阿里源
修改maven/conf/settings.xml
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/maven/repo</localRepository>
-->
<!--将注释去掉,将 <localRepository></localRepository>修改为自定义repository的路径。-->
<localRepository>/path/maven/repo</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>
<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>
IntelliJ IDEA 进行maven配置
打开开发工具 IntelliJ IDEA,进行maven配置:File-Settings-Build,Execution,Deployment-Build Tools-Maven
修改’Maven home directory’、‘User settings file’、‘Local repository’,点击’apply’-'ok’按钮结束。
IntelliJ IDEA中新建maven项目
点击Finsh
按钮,等待加载即可完成。