Create Maven Projects Fast

Source: Internet
Author: User

Download installation Download

official: http://maven.apache.org/download.html

free to install, unzip maven to the specified directory , such as:D:\Program Files (x86) \apache\apache-maven-3.0.4

Note: Before installing maven , make sure that you have installed the JDK and successfully configured its environment variables.


Configuring Environment variables

( 1 computer , properties , Advanced system Settings , environment variable

(2) New system environment variable: variable name maven_home , the value of the variable is the root directory after MAVEN decompression.

take my configuration as an example: Maven_home = D:\Program Files (x86) \apache\apache-maven-3.0.4

(3) Update the PATH System environment variable, add ;%maven_home%\bin; to the tail.

(4) test If Maven configuration is successful: Open Command Line window, enter mvn-version, if maven The version information output proves that the configuration was successful, otherwise check that your configuration path is correct.


CreateMavenProject Auto-creationMavenProject

Open cmdand go to the directory where you want to create the project.

Enter the following command

MVN archetype:Generate-DgroupId=com.MyCompany.app-DartifactId=my-app-Darchetypeartifactid=maven-archetype-QuickStart-Dinteractivemode=false

after execution, a directory will be generated under the directories you specify Maven Project. The directory structure is as follows:

Src/main/java is the source directory, Src/test/java is the test code catalog, pom.xml is the projectobject model, which is the core configuration file for the Maven project.

CompileMavenProject

(1) Enter the project directory and enter MVN Package

After the command is executed, the compilation results are displayed.

If the compilation succeeds, the target directory and output file are generated under the project directory .


(2) Implementation Java-CP Target/my-app-1.0-SNAPSHOT.jar com.MyCompany.app.App command,

The following results will be printed:

Hello world!

MavenMost commonly used commands

Validate: Verify that the project is correct and that all necessary information is valid.

Compile: Compile the source code for the project.

Test: testing compiled code with a test suite framework. These tests should not require code to be packaged or deployed.

Package: The compiled code is packaged in a path format, such as a jar package.

Integration-test: Deploy the package to an integrated test environment that can be run, if necessary.

Verify: Run any checks to verify that the package is valid and complies with the quality standards.

Install: installs the wrapped package to the local repository, which is referenced by other local projects.

Deploy: Copy the final package to an integration or release environment (remote warehousing) to share with other developers and projects.

Clean: Clears the output created by the last compilation.

Site: Generates a site document for this project .


Resources

Maven Official information:http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

Create Maven Projects Fast

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.