GXPT环境搭建——Maven环境的搭建
来源:互联网 发布:安芬尼.哈达威数据 编辑:程序博客网 时间:2024/05/20 22:39
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文件)。所以,这里的settings.xml一般不动。
b、用户settings.xml,拷贝%MAVEN_HOME%\conf\settings.xml文件到当前系统用户文件下的.m2下的settings.xml文件,并在其中修改为自定义的maven本地仓库存放位置(用户settings.xml并非一开始就有,它的意义在于不修改maven全局配置的情况下,更加合理对的配置用户自己的maven配置文件)。我们只在这里保存一份自定义的settings.xml,配置本地仓库(下载的jar都会放入到配置的D:\maven\repository下)。到时候构建项目的时候,需要用到的jar包,首先回来自定义仓库中寻找,如果没有找到,就从私服下载到这个仓库中!
<!-- 自定义本地仓库存放位置 --><localRepository>D:\maven\repository</localRepository>
c、自定义settings.xml文件,即拷贝%MAVEN_HOME%\conf\settings.xml文件到当前自定义用户自定义的maven本地仓库存放位置的同级目录下(自定义settings.xml同用户settings.xml一样,它的出现也是为了更加合理的使用maven的配置文件。)
<?xml version="1.0" encoding="UTF-8"?><settings xmlns="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.0 http://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>Local Repository</name><url>http://192.168.24.128:8081/nexus/content/groups/public/</url></mirror></mirrors><!-- 设置 nexus 的路径等 --><profiles><profile><id>nexus</id><repositories><repository><id>central</id><name>local private nexus</name><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>local private 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><!-- 激活 nexus --><activeProfiles> <activeProfile>nexus</activeProfile></activeProfiles><!-- 配置eclipse插件 --><pluginGroups><pluginGroup>org.mortbay.jetty</pluginGroup><pluginGroup>org.codehaus.cargo</pluginGroup></pluginGroups></settings>
这个配置文件配置内容:
1、本地仓库的路径
2、设置发布 jar 包时的用户名及密码。我们把各个模块构建成了jar或者war文件,发布到私服nexus中需要用到。
3、设置 maven 的远程仓库为 nexus并激活。项目添加jar依赖后,会从设置的本地仓库中查找,如果查找到了,自动添加到项目中;如果没有查到,会访问我们配置好的maven中央仓库,而这里使用<mirror>元素,拦截了对所有仓库的访问,换言之,对任何仓库的访问都会转成对nexus/content/groups/public仓库的访问,而这个仓库是一个仓库组,保持了对所有仓库的访问。
至此,Maven配置完成。
原先以为Maven只是一个构建工具,但其实Maven借助其丰富的插件实现了测试,打包,发布,构建等众多功能,如果有兴趣可以深入了解一下。
- GXPT环境搭建——Maven环境的搭建
- GXPT环境搭建——私服Nexus(一)
- GXPT环境搭建——私服Nexus(二)
- GXPT环境搭建——私服Nexus更新索引(三)
- Maven环境的搭建
- Maven 环境的搭建
- Maven环境的搭建
- Maven环境的搭建
- maven的环境搭建
- maven的环境搭建
- Maven环境的搭建
- Maven的环境搭建
- maven环境的搭建
- Maven的环境搭建
- maven学习——搭建Maven环境
- Maven 搭建Maven环境
- Maven环境的快速搭建
- Maven环境搭建的步骤
- 开坑,cocos2dx从零学起记录
- HTTP协议详解
- Spiral Matrix
- .NET基础之自定义泛型
- 用C++设计一个不能被继承的类
- GXPT环境搭建——Maven环境的搭建
- 安装mysql总结
- ZOJ 3329 One Person Game 概率DP
- HTTP协议 (二) 基本认证
- hdu 2099 整除的尾数
- HTTP协议 (三) 压缩
- 字典
- 系统架构师
- 图像滤镜艺术--暴雨滤镜