1、maven安装
1》http://maven.apache.org/download.cgi下载apache-maven-3.6.1
2》解压缩安装包到指定的文件夹,如C:\fyliu\software\apache-maven-3.6.1
3》配置maven用户环境变量MAVEN_HOME
4》设置Http访问代理
5》配置本地库路径
6》配置镜像
<mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror>
7》配置用户范围setting.xml
2、maven的pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.lfy.cn</groupId> <artifactId>helloworld</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>maven helloworld project</name> </project>
说明:
project元素:是所有pom.xml的根元素。
modelVersion:指定当前pom模型的版本,maven2、maven3只能是4.0.0
groupId:定义项目属于哪个组
artifactId:定义当前maven项目在组中的唯一ID
version:指定了项目当前的版本
groupId、artifactId、version:定义了一个项目的基本坐标。