网站首页 > 博客文章 正文
一、简介
在这篇文章中,笔者将介绍如何在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-21 Java技术干货|利用Maven进行java项目构建应用常见功能
- 2024-09-21 MyEclipse中文教程六:新建Maven Web项目的步骤
- 2024-09-21 Java-Maven详解(maven javadoc)
- 2024-09-21 Maven如何统一管理团队后端项目开发技术栈?
- 2024-09-21 IntelliJ IDEA上创建Maven Spring MVC项目
- 2024-09-21 maven安装好了,接下来教你搭建ssm
- 2024-09-21 超全Maven常用命令(maven的使用教程)
- 2024-09-21 maven生成可执行的jar文件的两种方法
- 2024-09-21 两分钟学会编写maven插件(maven 插件)
- 2024-09-21 Maven实战总结(maven从入门到精通)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)