java(IDEA)中maven配置
基于Maven工程的java项目环境配置
1、maven工具下载地址及安装教程
github下载路径 https://github.com/zhangweiweiweiweiwei/Maven.git maven(1).zip文件
官网maven工具下载地址:http://maven.apache.org/download.cgi
2、maven环境变量配置
- 打开环境变量配置。右键计算机→属性→高级系统设置→高级→环境变量,在系统变量中配置。
- 配置MAVEN_HOME。在系统变量中新建,变量名MAVEN_HOME,变量值,maven文件夹路径,我的路径是D:mavenapache-maven-3.5.4-binapache-maven-3.5.4,最好不要有中文,我比较懒,不想改,保存。
- 配置path,找到path系统变量,点开,新建,入%MAVEN_HOME%in
- 验证是否安装完成,运行cmd,输入mvn -v,显示maven版本则成功。
3、配置本地仓库(配置setting.xml文件第54行左右)
<localRepository>D:mavenapache-maven-3.5.4-binmaven_repository</localRepository>
4、配置阿里云快速下载jar包(配置setting.xml文件第161行左右)
<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>
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
</mirrors>`
5、maven项目在IDEA 中的配置
此处则maven工具基本完成,若需配置maven工程在IDEA中的java项目使用,请继续浏览后续内容。 永久配置则需在idea未打开(或已打开关闭项目close Project的情况下配置) 点击configure --> settings进行配置 检索maven,框内需修改。 修改为: maven到此配置基本结束,若不想永久设置,则需每次创建项目后进行file–>settings 进行配置,此为单一项目配置,即每次新建项目都必须配置一次。记得检查。
