Java-maven project management and maven Project Management

Source: Internet
Author: User

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:

  

  • A maven case

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:

  

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.