introduce
Maven is based on the Project Object Model (POM) and uses a short description to download dependencies, handle dependencies, package, build projects, and more.
Maven’s directory structure
A Maven project must have the following structure, otherwise it cannot be identified as a Maven project. Com.wqlm. test is the package directory for the project, and target is the temporary directory after the project is compiled
src
-main
-java
-com.wqlm.test
-test
-java
-com.wqlm.test
-resources
target
-class
Copy the code
Common build commands
- Compile the project
mvn compile
- performThe test case
mvn test
- Packaging project
mvn package
- Delete target directory
mvn clean
- Install jar packages into the local repository
mvn install
Install jar packages locally
MVN install: install-file-dfile =jar package path -dgroupid =groupId -dartifactid =artifactId -dversion = version -dpackaging =jarCopy the code
Pom – 4.0.0. XML
Maven in the installation directory/lib directory, there is a maven – model – builder – 3.3.9. Jar jar package, After decompression in maven – model – builder – 3.3.9 / org/apache/maven/model in a certain pom – 4.0.0. XML file.
This file is the root POM, from which all POMs implicitly inherit.
There’s a lot in there, so let’s just look at this part of the central warehouse
<repositories> <repository> <! <id>central</id> <name> central Repository</name> <! - this is the official maven central warehouse address - > < url > https://repo.maven.apache.org/maven2 < / url > < layout > default < / layout > < snapshots > <! -- Disable download of snapshot version --> <enabled>false</enabled>
</snapshots>
</repository>
</repositories>
Copy the code
Notice the
central