Getting started with Maven-1. Introduce and build a development environment

Source: Internet
Author: User

# # # # # Maven Introduction

MAVEN is a software project management tool that is based on a Project object model (POM) that can manage the construction, reporting, and documentation of a project through a short description of the information. MAVEN is a project management tool that contains a project object model? (Project?) Object? Model), a set of standard collections, a Project life cycle (project? Lifecycle), a dependency management system (Dependency? Management? System), and the logic used to run the plug-in (plugin) target (goal) defined in the life cycle phase (phase).
All project configuration information is defined in a file called Pom.xml, through which Maven can manage the entire declaration cycle of a project, including compiling, building, testing, publishing, reporting, and so on. Currently, most of Apache's projects have been managed using MAVEN. MAVEN itself also supports a variety of plugins, allowing for more flexible control of the project
**maven Core * * Actually do not do what the actual things, in addition to parsing some? XML? document, Manage life cycle and plugins, it doesn't understand anything. Maven is designed to delegate the primary responsibility to a group? Maven plugins, can these plugins affect? Maven life cycle, providing access to your goals.
#####?1.1? Comparison of Maven and Ant?
ANT: You need to tell it what to do, how to do it, where to put it.
1.?? In ant, you need to tell it exactly what you want it to do, you need to tell it in a step-by-step, where the source code is, where the class file is compiled, and then you want to make a war package.
2.?? Ant is a display call, it does not agree on a project generic directory structure, you must explicitly tell it where the directory is, what is the directory?
3.?? Ant has no life cycle

Maven:
1.?? Maven has a contract: What directory does it agree on?
2.?? MAVEN is declarative: All operations are in Pom.xml, others are given to Maven
3.?? Maven has a life cycle: A series of steps are executed during a Maven life cycle, and Maven runs many plug-in targets.


# # # # # # # # Build MAVEN Environment
Download maven:http://maven.apache.org/download.html
Then extract to a directory to
#####?2.1? Configuring environment variables
Add a Maven_home:maven installation directory
Then add the path in path to the bin directory of MAVEN's home directory
For example:
maven_home:d:\apache-maven-3.0.3
The top of path is added: D:\apache-maven-3.0.3\bin;
#####?2.2? Test Installation Success
Open cmd input: mvn?-v
Show Apache? maven?3.3.9? version information is successful
#####?2.3? Configure the local warehouse location for MAVEN
The so-called local repository is maven download the jar storage path (default in the user's. M2 directory)
The default Maven local warehouse location is typically in the user directory of the C drive, which takes up space. General to adjust the location of the warehouse
Open the Settings.xml file in the apache-maven-3.0.3\conf directory
Locate the following line and add a row below
"' XML
<!--? localrepository
????|? The?path?to?the?local?repository?maven?will?use?to?store?artifacts.
????|? Default:?~/.m2/repository
?<localrepository>/path/to/local/repo</localrepository>
-
```

Add your own warehouse location
"' XML
<localRepository>E:/JavaDev/maven/repository</localRepository>
```

and finally copy the. settings.xml file you just set to your local repository s? Under the E:/javadev/maven/repository directory


# # # # # # # # of Maven's engagements

In the case of no customization:
Java source code is assumed to be under ${basedir}/src/main/java
The resource configuration file is assumed to be under ${basedir}/src/main/resources
The test code is assumed to be under ${basedir}/src/test
The resource used for the test is assumed to be under ${basedir}/src/test/resources
The compiled class file is assumed to be under ${basedir}/target/classes
The generated jar package and the war package are assumed to be under ${basedir}/target
Pom.xml file under ${basedir}


Maven Project Type:
1.?maven-archetype-j2ee-simple? (EE. Project)
2.?maven-archetype-portlet? Portal
3.?maven-archetype-quickstart? General? Java?project)
4.?maven-archetype-site? (Complex site)
5.?maven-archetype-site-simple? (Simple site)
6.?maven-archetype-webapp? (Java?) Web? site)

# # # # # The installation directory structure of MAVEN

**bin**:? This directory contains scripts that are run by MVN, which are used to configure Java commands, prepare classpath and related Java System Properties, and then execute Java commands.
**boot**:? This directory contains only one file, for example, maven?3.0? The file is? Plexus-classworlds-2.2.3.jar. plexus-classworlds
is a classloader framework, relative to the default? Java ClassLoader, which provides richer syntax for easy configuration, Maven? Use this framework to load your own class library
**conf**:?? This directory contains a very important file? settings.xml.
**lib**:?? This directory contains all of the? What does Maven need at runtime? Java? Class Library. Where the MAVEN core jar file is (Maven-\*.\*-uber.jar)






From for notes (Wiz)

Getting started with Maven-1. Introduce and build a development environment

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.