Get started with Maven

Source: Internet
Author: User

Introduction to Maven

Maven is a project management tool that contains a project object model, a set of standard sets, and a project lifecycle ), A dependency management system and logic used to define the plug-in goal (Gole) in the lifecycle phase (phase. When using Maven, you use a clearly defined project object model to describe your project.

Comparison between Maven and ant

Ant is just a building tool that focuses on preprocessing, compilation, packaging, testing, and distribution. Maven is an ant superset. It is a project lifecycle management tool that focuses not only on the build phase, but also on generating reports and web sites.

● Ant

Ant does not specify the directory structure of a general project. It must clearly tell ant where to findSource codeAnd so on.

Ant isProgramIt is necessary to tell it when to do something.

Ant does not have a life cycle. dependencies between the target and the target must be defined, for example, configuring a task for each target.

● Maven

Maven has a convention. MAVEN knows where to find the source as agreed.CodeAnd so on.

Maven is declarative. You only need to create a pom. xml file to know what to do.

Maven has a life cycle. When running Maven install, this statement tells Maven to execute a series of steps, which are also agreed upon and do not need to manually specify the execution sequence.

The options of ant and Maven are not static. For example, if your current build lifecycle needs to be highly customizable, the fixed life cycle of Maven is not suitable.

Core Idea of Maven-better than Configuration

The system, class library, and framework should assume a reasonable default value, instead of providing unnecessary configuration. Although the configuration can be customized according to personal circumstances and preferences, however, the collaboration between project personnel is seriously affected.

Maven conventions:

Source code: src/main/Java

Resource file: src/main/Resource

Test code: src/test

Compiled binary file:/target/classes

Final files that can be distributed (. jar,. War,. Ear):/Target

(If you change to an unspecified ant that is better than the configured one, you need to configure the directory for each of the above tasks. If you need to configure the path for special requirements, Maven also supports manual configuration, but the default is the above conventions)

Core cause of Maven success-unified interface for project configuration

In the past, it was very difficult to check out two projects from the version server to package them into a final publishable file, because you need to understand the structure of the two projects, what needs to be released separately and where everything should be placed. Now, new programmers don't need to understand this. They only need to execute Maven install to facilitate building.

Maven Repository

Maven provides a free central repository for Java developers all over the world, where almost any popular open-source class libraries can be found. It also supports private server (local server) repositories, it is faster to obtain the class library. Through some Maven derivative tools (such as nexus), we can quickly search for them.

Maven is plug-in-based

Maven does not do anything. Almost all operations are performed on the plug-in. The first command execution will download the command from the central server to execute the plug-in.

 

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.