接下来会使用到maven,所以这一章节简单的介绍下maven,以及maven配置
1.下载maven
到官网下载:http://maven.apache.org/download.cgi
根据自己的系统进行选择
![]()
下载完成后解压出来
2.配置环境变量
跟配置java 环境变量是一样的,这里还是简单的说下
我的电脑-右键属性-高级-环境变量
新建一个M2_HOME
![]()
然后再path中添加 %M2_HOME%\bin 保存
打开doc控制台,执行mvn -version
如果没有报错,输出了maven的版本信息就表示maven环境变量配置成功
3.maven基本配置
3.1.配置本地目录
打开maven安装目录中conf目录下的settings.xml目录
找到这里,配置一个你自己的目录
3.2.配置maven私服
默认的私服是https://mvnrepository.com/ 从这里比较慢。阿里的私服还是比较稳定 地址
http://maven.aliyun.com/nexus/,而且速度也是杠杆的,配置如下
<profile>
<id>jdk-1.7</id>
<activation>
<jdk>1.7</jdk>
</activation>
<repositories>
<repository>
<id>aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
这样maven的基本配置就OK了。
PS:我们习惯使用工具自带的工具来打包项目,其实用mvn命令更好使 mvn clean install -U 或者 mvn clean package -U 命令的意思是 清除项目,强制更新项目,然后打包。