Java-maven project management and maven Project Management
- Maven is a software project management tool based on the project Object Model (POM). You can use a short description to manage project building, reporting, and documentation.
- Build a Maven Environment
Bytes
Configure environment variables:
Whether the configuration is successful:
1. maven directory structure:
src -main -java -package -test -java -package resources
2. Add the pom. xml file under the root directory (same as src)
<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. maven01 </groupId> <artifactId> maven01-model </artifactId> <version> 0.0.1SNAPSHOP </version>
<! -- Use the Junit4 framework to test the code, dependencies to import to Junit --> <dependencies> <dependency> <groupId> junit </groupId> <artifactId> junit </artifactId> <version> 4.10 </version> </dependency> </dependencies> </project>
Note: groupId: Organization ID, that is, the package name of the project.
ArtifactId: Module name, for example, my-project. In the M2_REPO directory, the module name will be the org/codehaus/mojo/my-project directory.
Version: version number. For example, NAPSHOP is a snapshot version.
3. Run the following command line:
Mvn compile compiles the project
Mvn test run test case
Mvn package. The project is packaged into A. jar file.
After the execution is complete, some files are generated in the root directory:
Mvn clean: Delete the target directory of the target file produced by maven
Mvn install the jar package to the local repository
- Two ways to create a directory
1. mvn archetype: generate select as prompted
Define value for property 'groupId': com.test.maven03Define value for property 'artifactId': maven03-serviceDefine value for property 'version' 1.0-SNAPSHOT: : 1.0.0SNAPSHOTDefine value for property '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, company website anti-write + project name
-DartifactId = project name-Module name
-Dversion = version number
-Dpackage = Name of the package in the code
The last directory automatically created: