一。maven介绍
引用比较经典的一句话, Apache Maven 的定义: Maven是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个依赖管理系统(Dependency Management System),和用来运行定义在生命周期阶段(phase)中插件(plugin)目标(goal)的逻辑。 当你使用Maven的时候,你用一个明确定义的项目对象模型来描述你的项目,然后 Maven 可以应用横切的逻辑,这些逻辑来自一组共享的(或者自定义的)插件。
二。安装maven
下载apache-maven-2.1.0。解压到相应的目录,这里为d:
三。设置环境变量
3-1)添加系统环境变量M2_HOME,指向maven的安装路径(上述为:X:\xx\apache-maven-2.1.0),确认结尾不含字符“\”;
3-2)添加系统环境变量M2,指向%M2_HOME%\bin;
3-3)[可选]添加系统环境变量MAVEN_OPTS,值设为-Xms256m -Xmx512m,用于控制maven使用jvm的属性;
3-4)更新系统环境变量Path,添加路径%M2%;
3-5)确认环境变量JAVA_HOME已经正确配置,并且环境变量Path中包含%JAVA_HOME%\bin;
3-6)[可选]安装eclipse插件m2eclipse.rar:
在eclipse中使用如下链接进行安装和更新:http://m2eclipse.sonatype.org/update/
四。设置配置文件(关于这部分将会在《搭建Maven2私服》详细介绍)
3-1)修改全局配置文件%M2_HOME%/conf/settings.xml
将节点profiles和activeProfiles的内容修改为如下内容:
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>local nexus server</name>
<url>http://10.1.10.29/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>local nexus</name>
<url>http://10.1.10.29/maven2</url>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>localrepo</id>
<repositories>
<repository>
<id>artifactory</id>
<name>artifactory at local</name>
<!-- change to your local artifactory url -->
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>artifactory</id>
<name>artifactory at local</name>
<!-- change to your local artifactory url -->
<url>http://repo1.maven.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
3-2)添加用户配置文件
在用户目录(命令行中使用“echo %USERPROFILE%”可以查看)下创建目录“.m2”
在目录“.m2”下创建空白文件settings.xml,内容修改为如下:
<settings> <localRepository>E:/mavenRepository</localRepository>
<servers>
<server>
<id>deploymentReleases</id>
<username>test</username>
<password>password</password>
</server>
<server>
<id>deploymentSnapshots</id>
<username>test</username>
<password>password</password>
</server>
</servers>
</settings>
五。验证配置真确性
在命令行运行mvn -v 如果输出:
Maven version: 2.1.0
Java version: 1.4.2_13
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
就表示安装ok
引用比较经典的一句话, Apache Maven 的定义: Maven是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个依赖管理系统(Dependency Management System),和用来运行定义在生命周期阶段(phase)中插件(plugin)目标(goal)的逻辑。 当你使用Maven的时候,你用一个明确定义的项目对象模型来描述你的项目,然后 Maven 可以应用横切的逻辑,这些逻辑来自一组共享的(或者自定义的)插件。
二。安装maven
下载apache-maven-2.1.0。解压到相应的目录,这里为d:
三。设置环境变量
3-1)添加系统环境变量M2_HOME,指向maven的安装路径(上述为:X:\xx\apache-maven-2.1.0),确认结尾不含字符“\”;
3-2)添加系统环境变量M2,指向%M2_HOME%\bin;
3-3)[可选]添加系统环境变量MAVEN_OPTS,值设为-Xms256m -Xmx512m,用于控制maven使用jvm的属性;
3-4)更新系统环境变量Path,添加路径%M2%;
3-5)确认环境变量JAVA_HOME已经正确配置,并且环境变量Path中包含%JAVA_HOME%\bin;
3-6)[可选]安装eclipse插件m2eclipse.rar:
在eclipse中使用如下链接进行安装和更新:http://m2eclipse.sonatype.org/update/
四。设置配置文件(关于这部分将会在《搭建Maven2私服》详细介绍)
3-1)修改全局配置文件%M2_HOME%/conf/settings.xml
将节点profiles和activeProfiles的内容修改为如下内容:
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>local nexus server</name>
<url>http://10.1.10.29/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>local nexus</name>
<url>http://10.1.10.29/maven2</url>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>localrepo</id>
<repositories>
<repository>
<id>artifactory</id>
<name>artifactory at local</name>
<!-- change to your local artifactory url -->
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>artifactory</id>
<name>artifactory at local</name>
<!-- change to your local artifactory url -->
<url>http://repo1.maven.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
3-2)添加用户配置文件
在用户目录(命令行中使用“echo %USERPROFILE%”可以查看)下创建目录“.m2”
在目录“.m2”下创建空白文件settings.xml,内容修改为如下:
<settings> <localRepository>E:/mavenRepository</localRepository>
<servers>
<server>
<id>deploymentReleases</id>
<username>test</username>
<password>password</password>
</server>
<server>
<id>deploymentSnapshots</id>
<username>test</username>
<password>password</password>
</server>
</servers>
</settings>
五。验证配置真确性
在命令行运行mvn -v 如果输出:
Maven version: 2.1.0
Java version: 1.4.2_13
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
就表示安装ok