基于idea的maven配置
一、下载Maven
下载Maven :apache-maven-3.6.0-bin.tar.gz
官方地址:http://maven.apache.org/download.cgi
二、修改setting.xml文件
在apache-maven-3.6.0 /conf/settings.xml中修改如下操作(可以用Notepad++打开)
在注释外加入
注意:
当我的maven装在非c盘时,只有在c盘下执行 mvn -v才能显示maven版本号,其他盘下调出来cmd就会报:
‘mvn’ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
解决:将maven装在c盘,非c盘下就可以执行mvn命令了
新建一个空仓库,例如:C盘的MAVEN
配置阿里云
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>ui</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://uk.maven.org/maven2/</url>
</mirror>
<mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
<mirror>
<id>OSChina</id>
<name>OSChina Central</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>nexus-osc-thirdparty</id>
<mirrorOf>thirdparty</mirrorOf>
<name>Nexus osc thirdparty</name>
<url>http://maven.oschina.net/content/repositories/thirdparty/</url>
</mirror>
更新类库
三、配置maven环境变量
控制面板→系统→高级系统设置→环境变量
系统变量→新建MAVEN_HOME变量(变量值填写maven的安装目录(C:\apache-maven-3.6.0))
系统变量→寻找Path变量→编辑 (在变量值最后输入 %MAVEN_HOME%\bin;)
四、在idea中配置maven