项目进阶 之 持续构建环境搭建(三)Maven环境搭建
来源:互联网 发布:合肥淘宝摄影 编辑:程序博客网 时间:2024/05/20 13:38
1、前提
安装mavne首先需要安装JDK,并配置环境变量。这部分比较简单,就不再做演示了。2、安装
直接解压文章末尾提供的apache-maven-3.1.1-bin.zip文件到D:\maven\apache-maven-3.1.1(可自定义文件位置)即可完成安装。3、配置
1)、环境变量右键 我的电脑->属性->高级系统设置->环境变量,进行如下设置。
a、在用户变量中添加MAVEN_HOME=D:\maven\apache-maven-3.1.1
b、修改PATH,在配置中添加%MAVEN_HOME%\bin;c、调出命令行窗口(win + r 之后输入cmd)
d、输入mvn –version,出现界面如下,则安装Maven配置成功
2)、settings.xml文件配置
Maven中最重要的配置就是settings.xml文件的配置,其默认位置为%MAVEN_HOME%\conf\settings.xml,相关具体配置如下:
a、全局settings.xml位于%MAVEN_HOME%\conf\settings.xml,在该文件中配置的任何选项对于使用maven的所有应用程序均会产生影响,且影响力最大。(该文件如果不做任何修改,在第一次启动maven之时会在当前用户的文件夹下建立一个.m2的文件夹,其中存放了maven本地的所有jar文件)
b、用户settings.xml,拷贝%MAVEN_HOME%\conf\settings.xml文件到当前系统用户文件下的.m2下的settings.xml文件,并在其中修改为自定义的maven本地仓库存放位置(用户settings.xml并非一开始就有,它的意义在于不修改maven全局配置的情况下,更加合理对的配置用户自己的maven配置文件)。
<!--localRepository| The path to the local repository mavenwill use to store artifacts.|| Default: ${user.home}/.m2/repository<localRepository>/path/to/local/repo</localRepository>--><!-- 自定义本地仓库存放位置 --><localRepository>D:/maven/repository</localRepository>
c、自定义settings.xml文件,即拷贝%MAVEN_HOME%\conf\settings.xml文件到当前自定义用户自定义的maven本地仓库存放位置的同级目录下(自定义settings.xml同用户settings.xml一样,它的出现也是为了更加合理的使用maven的配置文件。)
修改settings.xml内容,具体如下:
<?xmlversion="1.0" encoding="UTF-8"?><settingsxmlns="http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0http://maven.apache.org/xsd/settings-1.0.0.xsd"><!-- 设置本地仓库路径 --><localRepository>D:/maven/repository</localRepository><!-- 设置发布 jar 包时的用户名及密码 --><servers><server><id>releases</id><username>admin</username><password>admin123</password></server><server><id>snapshots</id><username>admin</username><password>admin123</password></server> </servers><!-- 设置 maven 的远程仓库为 nexus--><mirrors><mirror><id>nexus</id><mirrorOf>*</mirrorOf><name>LocalRepository</name><url>http://192.168.24.252:8081/nexus/content/groups/public</url></mirror></mirrors><!-- 设置 central 的路径等 --><profiles><profile><id>central</id><repositories><repository><id>central</id><name>Central</name><!-- 该 url 没有意义,可以随便写,但必须有。 --><url>http://localhost:8081/nexus/content/groups/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>central</id><name>localprivate nexus</name><url>http://localhost:8081/nexus/content/groups/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories></profile></profiles><!-- 激活 central --><activeProfiles><activeProfile>central</activeProfile></activeProfiles><!-- 配置eclipse插件 --><pluginGroups><pluginGroup>org.mortbay.jetty</pluginGroup><pluginGroup>org.codehaus.cargo</pluginGroup> </pluginGroups></settings>
到此为止,对于Maven的配置我们就讲解完毕了。这里重点给大家强调一点的是,maven只是一个管理型的构建工具,它的功能很多,也有很多丰富的插件,很多人错误的认为maven只是一个构建工具,这一点是非常值得大家借鉴的。
持续更新中,敬请期待!
apache-maven-3.1.1-bin.zip下载地址如下:
http://mirrors.hust.edu.cn/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.zip
- 项目进阶 之 持续构建环境搭建(三)Maven环境搭建
- 项目进阶 之 持续构建环境搭建(一)架构
- 项目进阶 之 持续构建环境搭建(四)Jenkins环境搭建
- 项目进阶 之 持续构建环境搭建(二)Nexus私服器
- 【项目管理】Jenkins+Maven+Git项目持续构建之搭建JDK/Maven基础环境
- 项目构建之maven篇:1.环境搭建
- maven项目环境搭建
- maven项目环境搭建
- 项目进阶 之 集群环境搭建(三)多管理节点MySQL集群
- 项目进阶 之 集群环境搭建(一)概述
- 项目进阶 之 集群环境搭建(二)MySQL集群
- 项目进阶 之 集群环境搭建(二)MySQL集群
- 项目进阶 之 集群环境搭建(一)概述
- 【项目管理】之maven+nexus环境搭建
- Hudson+Maven+SVN 搭建持续集成环境
- Hudson+Maven+SVN 搭建持续集成环境
- Hudson+Maven+Svn搭建持续集成环境
- Hudson+Maven+Svn搭建持续集成环境
- 平衡二叉树的生成理论
- POJ-2431-Expedition
- MD5算法 C#
- 理工大学ACM平台题答案关于C语言 2249 做乘法
- 揭秘:一款App的开发成本是多少?
- 项目进阶 之 持续构建环境搭建(三)Maven环境搭建
- Visual Studio中应用代码更改不可用的解决方案
- 中国计算机学会推荐国际学术会议(数据库)
- 平衡二叉树AVL的笔记
- JAX-WS与Struts2的结合使用
- 平衡二叉树
- SQL Server 存储过程
- linux环境下制作windows/linux系统启动盘(个人的尝试过程)
- 杭电ACM——2010