网站首页 > 编程文章 正文
一、简介
在这篇文章中,笔者将介绍如何在windows下搭建Maven环境。
二、系统需求
Java SE Development Kit 7
Maven 3.3.9
三、下载压缩包
Maven官网下载压缩包,即:apache-maven-3.3.9-bin.zip
https://archive.apache.org/dist/maven/maven-3/3.3.9/
四、解压压缩包
建议将apache-maven-3.3.9-bin.zip解压至某盘符的根目录下,尽量不要放入中文或者包含其它特殊字符的目录中,笔者将其解压至D:\maven3.3.9。
五、配置环境变量
通过点击“控制面板\系统和安全\系统\高级\环境变量\系统变量”的path变量添加如下路径:D:\maven3.3.9\bin
打开windows的命令行窗口,输入以下代码:
C:\Users\DHC>mvn -v Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00) Maven home: D:\maven3.3.9 Java version: 1.7.0_80, vendor: Oracle Corporation Java home: D:\Java\jdk1.7.0_80\jre Default locale: zh_CN, platform encoding: GBK OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
若出现上述结果,则证明环境变量配置成功(注:需要前置条件为已经配置好JDK环境)。
六、配置Maven其它内容
1. 配置Maven本地仓库位置
在Maven目录中创建空目录,如:D:\maven3.3.9\repo
打开文件D:\maven3.3.9\conf\settings.xml修改本地仓库位置
<!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <!--将下面这行修改自定义的本地仓库位置即可 --> <localRepository>D:\maven3.3.9\repo</localRepository>
2. 配置Maven镜像站点
打开文件D:\maven3.3.9\conf\settings.xml修改镜像
<!-- mirrors | This is a list of mirrors to be used in downloading artifacts from remote repositories. | | It works like this: a POM may declare a repository to use in resolving certain artifacts. | However, this repository may have problems with heavy traffic at times, so people have mirrored | it to several places. | | That repository definition will have a unique id, so we can create a mirror reference for that | repository, to be used as an alternate download site. The mirror site will be the preferred | server for that repository. |--> <mirrors> <!-- 这里可以添加多组镜像,以下这组添加的是阿里镜像站点 --> <mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> </mirrors>
2. 配置Maven多组文件列表
<!-- profiles | This is a list of profiles which can be activated in a variety of ways, and which can modify | the build process. Profiles provided in the settings.xml are intended to provide local machine- | specific paths and repository locations which allow the build to work in the local environment. | | For example, if you have an integration testing plugin - like cactus - that needs to know where | your Tomcat instance is installed, you can provide a variable here such that the variable is | dereferenced during the build process to configure the cactus plugin. | | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles | section of this document (settings.xml) - will be discussed later. Another way essentially | relies on the detection of a system property, either matching a particular value for the property, | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'. | Finally, the list of active profiles can be specified directly from the command line. | | |--> <!-- JDK7环境 --> <profiles> <profile> <id>jdk-1.7</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.7</jdk> </activation> <properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion> </properties> </profile> </profiles>
七、总结
本文简述了搭建Maven环境,可以在IDE(集成开发环境)中添加Maven相关配置。
可通过如下命令查询搭建的环境是否成功(详细内容请查看笔者下篇文章):
mvn archetype:generate -DgroupId=com.dhc.simpleweb -DartifactId=simple-webapp -Dpackage=com.dhc.simpleweb -DarchetypeArtifactId=maven-archetype-webapp -Dversion=1.0-SNAPSHOT -DinteractiveMode=false
猜你喜欢
- 2024-09-10 精品基于SSM的旅游信息管理系统的设计与实现
- 2024-09-10 ElasticSearch 插件部署及介绍(elasticsearch插件安装)
- 2024-09-10 基于微信小程序的高校餐厅食品留样管理系统-毕业设计源码+LW文档
- 2024-09-10 精品基于Uniapp+SSM实现的实验室设备预约管理APP
- 2024-09-10 基于微信小程序的药店管理系统-计算机毕业设计源码+LW文档
- 2024-09-10 基于微信小程序的高校餐厅食品留样管理系统-计算机毕业设计源码
- 2024-09-10 基于微信小程序的校园商铺系统-计算机毕业设计源码+LW文档
- 2024-09-10 基于SSM的奇石交易系统的设计与实现-计算机毕业设计源码+LW文档
- 2024-09-10 精品基于Uniapp+SSM实现的Android安全网购平台
- 2024-09-10 最新SpringBoot3.x原生镜像-Native Image尝鲜
你 发表评论:
欢迎- 06-24一个老爸画了超级有爱的365幅画 | 父亲节献礼
- 06-24产品小白看魏则西事件——用产品思维审视百度推广
- 06-24某教程学习笔记(一):13、脚本木马原理
- 06-24十大常见web漏洞——命令执行漏洞
- 06-24初涉内网,提权那些事(内网渗透提权)
- 06-24黑客命令第16集:47种最常见的**网站方法2/2
- 06-24铭说 | 一句话木马的多种变形方式
- 06-24Java隐藏的10倍效率技巧!90%程序员不知道的魔法方法(附代码)
- 最近发表
- 标签列表
-
- spire.doc (70)
- instanceclient (62)
- solidworks (78)
- system.data.oracleclient (61)
- 按键小精灵源码提取 (66)
- pyqt5designer教程 (65)
- 联想刷bios工具 (66)
- c#源码 (64)
- graphics.h头文件 (62)
- mysqldump下载 (66)
- libmp3lame (60)
- maven3.3.9 (63)
- 二调符号库 (57)
- git.exe下载 (68)
- diskgenius_winpe (72)
- pythoncrc16 (57)
- solidworks宏文件下载 (59)
- qt帮助文档中文版 (73)
- satacontroller (66)
- hgcad (64)
- bootimg.exe (69)
- android-gif-drawable (62)
- axure9元件库免费下载 (57)
- libmysqlclient.so.18 (58)
- springbootdemo (64)
本文暂时没有评论,来添加一个吧(●'◡'●)