- MAVEN is a software project management tool that enables you to manage project builds, reports, and documents through a small section of information that is based on the Project object Model (POM).
- MAVEN Environment Setup
http://maven.apache.org/download.cgi download Apache-maven-3.5.0-bin.zip, unzip to a directory
To configure environment variables:
is configured successfully:
1.maven directory structure:
src -main -java -Package -test -java - Package Resources
2. In the root directory (same as SRC sibling), add the Pom.xml file
<Projectxmlns= "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.maven01</groupId> <Artifactid>Maven01-model</Artifactid> <version>0.0.1SNAPSHOP</version>
<!--test the code with the JUNIT4 framework and need to import JUnit's dependency-- <Dependencies> <Dependency> <groupId>Junit</groupId> <Artifactid>Junit</Artifactid> <version>4.10</version> </Dependency> </Dependencies></Project>
Note: groupId: Organizational identity, which is the package name of the project.
Artifactid: module name, for example: My-project, in M2_repo directory, will be: Org/codehaus/mojo/my-project directory.
Version: Revision number. Example: Napshop is a snapshot version
3. Use the command line to perform the following:
MVN compile to compile a project
MVN Test Run Tests case
MVN package, the project is packaged into a. jar file.
After the execution completes, in the root directory, generate some files:
MVN clean Deletes the target directory that MAVEN produces
MVN Install the jar package into the local repository
- Two ways to create a table of contents
1.MVN archetype:generate Follow the prompts to select
Define value forProperty'groupId': Com.test.maven03Define value forProperty'Artifactid': maven03-Servicedefine Value forProperty'version' 1.0-snapshot::1.0. 0SNAPSHOTDefine value forProperty' Package'com.test.maven03:: Com.test.maven03.serviceConfirm properties Configuration:groupid: Com.test.maven03artifactId:maven03-serviceversion:1.0. 0snapshotpackage:com.test.maven03.service y:: Y
2.MVN archetype:geenrate-dgroup= organization name, anti-write of company URL + project name
-dartifactid= Project Name-module name
-dversion= Version number
The package name that is present in the-dpackage= code
The last directory created automatically:
Java-maven Project Management