This article is mainly for the purpose of quickly building a maven environment, and some concepts will be omitted from their descriptions:
1. What is maven?
Maven is a cross-platform project management tool, mainly used for project construction and dependency management based on the java platform. Simply put, it is to use maven to get the jar package instead of manually adding the jar package
2. What does maven rely on to obtain jar packages?
There is one such file in maven project - pom.xml . It is used to allow users to configure their properties to obtain the corresponding jar package. Here, we briefly understand the writing of pom.xml
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId> <!-- 标识 -->
<artifactId>mavenDemo</artifactId> <!-- 项目名称 -->
<version>0.0.1-SNAPSHOT</version> <!-- 版本号 -->
<packaging>jar</packaging> <!-- 项目打包后为jar包 -->
<name>mavenDemo</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies> <!-- 所有依赖的jar包统一放在此节点下 -->
<dependency> <!-- 书写依赖,此节点主要有三个属性来定位到一个jar包:groupId、artifactId、version -->
<groupId>junit</groupId> <!-- 包名 -->
<artifactId>junit</artifactId> <!-- 项目名 -->
<version>3.8.1</version> <!-- jar包版本 -->
<scope>test</scope>
</dependency>
<!-- 如果需要书写其它jar包,就继续书写对应的dependency,同上 -->
<!-- ...... -->
</dependencies>
</project>
Three, maven download and installation
First of all, you need to install jdk and eclipse on your computer. If you haven't installed it, please configure its environment first. I won't explain it here.
1. Download Maven
Enter the official website: http://maven.apache.org/
2. Unzip Maven as follows and add environment variables to it
3. Edit setting.xml
<localRepository>D:\MyMavenLibs</localRepository>
<!-- 国内镜像静态服务器: -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
【Optional】
<server>
<id>tomcat</id>
<username>admin</username>
<password>admin</password>
</server>
<!-- 对应apache/conf/tomcat-users.xml: -->
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>