Maven tutorial Article 01: Introduction

Source: Internet
Author: User

1. Starting Point of Maven

No matter what project, technology, orProgramming LanguageWe must repeat the same development steps: coding, testing, packaging, publishing, and documentation. In fact, these steps are completely repetitive. So why let software developers repeat these jobs? The main task of developers should be to focus on business logic and implement it, rather than wasting time learning how to package, release, and so on in different environments ,...

Maven was born to free developers from these tasks.


2. What can Maven do?

  Maven was developed from an early build tool customized for Jakarta turbine and is now an independent software project management tool. Maven can:

1) understand and manage the entire software development cycle and reuse standard building processes, such as compilation, testing, and packaging. Maven can also reuse the building logic to a project through the corresponding metadata.

2) Maven is responsible for the entire project construction process. Developers only need to describe the basic project information in a configuration file: Pom. xml. That is to say, Maven users only need to answer "what" instead of "how ".


3. MAVEN is not just a build tool, but also provides:

1) declarative dependency management

2) centralized Component Library Management

3) Automatic Document generation

4) Automatic Report Generation

4. MAVEN Design Principles

  1) Convention over configuration (Convention is better than configuration ). In real life, there are many things that are common sense, and everyone on Earth knows. For example, how to cross the road (the red light stops the green light), how to open the door, and close the door. People have made default agreements on these things.

In the software development process, the principle is similar. If we have agreed in advance on the directory structure of all projects, the standard development process (compilation, testing ,...), Everyone follows this agreement. The management of software projects becomes much simpler. This concept is used in many popular frameworks, such as ejb3 and Ruby on Rails. The default directory structure in Maven is as follows:


We can see the following standard Maven directories:

    • SRC:Source codeDirectory. All sourcesCodeAll are stored in this directory. This directory contains the following:

1) Main: Put all source code here. For Java projects, there is also a sub-Directory: Java. For flex projects, it is Flex ,...

2) test: Put all unit test classes here.

    • Target: put all the compiled class files and the generated packaging files (. jar,. War,...) here.

2) Reuse build logic: Maven encapsulates the build logic into the plug-in for reuse purposes. In this way, Maven has plug-ins for compilation, unit test, and packaged plug-ins ,... Maven can be understood as a framework for managing these plug-ins.
3) declarative execution (declarative execution): All plug-ins in Maven are defined by declarations in pom. Maven will understand all the declarations in POM and execute the corresponding plug-ins.

 

5. Create a Maven Project

1) download Maven: http://maven.apache.org/

2) decompress the downloaded ZIP file to a local directory, for example, D: \ Maven

3) add D: \ Maven \ bin to the environment variable path.

4) run the following command line:

MVN-versionOr MVN-V

You should see the maven version number shown in:

5) run the following command to create a Maven project:

 

   code highlighting produced by actipro codehighlighter (freeware) 
http://www.CodeHighlighter.com/
--> MVN archetype : Create -dgroupid = net . Jianxi . tutorials
-dartifactid = helloworld
-dpackagename = net . Jianxi . tutorials

Shows the directory structure of the project:

 

Now you can run some Maven commands.

Compile: MVN compile

Unit test: MVN Test

Build and package: MVN package

Clean: MVN clean

Http://www.cnblogs.com/bluesfeng/archive/2010/09/06/1819585.html

 

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.