"Project management and Build"--maven download, install and configure (ii)

Source: Internet
Author: User

Directory

    • Objective
    • Preparatory work
    • Installation
    • Learn about the Maven warehouse
    • Configuration
    • Summarize
Objective

In the previous post, "Project management and Build"--maven introduction (i) we learned that Maven is a new way to build a project that makes our development easier and more efficient. The main thing Maven does is two things:

    1. Unified Development Specification and tools

    2. Unified Management Jar Package

He has done both of these things, and has done more things. Maven can also manage the entire declaration cycle of a project, including compiling, building, testing, publishing, reporting, and more. Currently, most of Apache's projects have been managed using MAVEN. MAVEN itself also supports a variety of plugins that allow for more flexible control of the project.

工欲善其事, its prerequisite. Let's play Maven, too! We have to download one first.

Preparatory work
    • Java Development Environment (JDK)

    • Maven:http://maven.apache.org/release-notes-all.html

Installation

Installing MAVEN is super simple, with a total of four steps:

    1. Download Maven, in fact, is a compressed package, decompression

    2. Configure Environment variables

      There are two environment variables that can be configured:

      • Maven_home = D:\maven\apache-maven-3.2.3

      • maven_opts =-xms128m-xmx512m (optional)

    3. Add "%maven_home%\bin;" At the end of the path variable.

      The above m2_home is a must to configure, if you want Maven to run faster, you can set the maven_opts according to their own circumstances.

    4. Finally, verify that the installation is successful

      Now we open cmd and enter:

      Mvn-v

      I think you will certainly see some information as shown in:

Congratulations, Maven installation is successful!

Before using Maven, we had to find out how Maven managed the jar package, which is what the Maven warehouse is doing.

Learn about the Maven warehouse

The most immediate benefit of using Maven is to manage jar packages in a unified way, where are these jar packages stored? They are in your local repository, the default address is in the C:\Users\ user name. m2 directory (You can modify this default address, of course), so let's change the default address below.

In fact, we can understand the "cache" of the local repository in order to store the jar package. When developing a project, the project first obtains the jar package from the local repository, and when the specified jar package is not available, the local repository downloads the jar package from the remote repository (or Central warehouse) and "caches" it to the local repository for future use.

The remote repository (central warehouse) is provided by Maven and can be accessed via http://search.maven.org/. As a result, the local warehouse becomes more and more large as the project accumulates. The following diagram provides a clear representation of the relationship between the project, the local repository, and the remote repository.

Now that Maven is installed, then the local warehouse will have, the default path in our C directory, for professionals, C disk is very dangerous, let's change the default configuration.

Configuration

Maven places the Downloaded class library (jar package) in a local directory, and if you want to redefine the location of the directory, you need to modify the configuration of the Maven local repository:

Modified files: D:\maven\apache-maven-3.2.3\conf\setting.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/ Settings-1.0.0.xsd ">                                    <!--localrepository |       The path to the local repository maven would use to store artifacts.       | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository>-->
             <localrepository>D:\maven\repository</localrepository></Settings>

Based on this configuration, MAVEN will save the downloaded class library to D:\maven\repository.

Experiment with what we just did. No, console input:

MVN Help:system

Effect:

If there is no problem, after executing the command, there will be many more files under D:\maven\repository, the files that Maven downloads from the central repository to the local repository, and Maven has started working for us.

Summarize

Such a good project management tool is still waiting for, hurriedly install to try it.

In the next blog post, we'll configure eclipse, combine it with Maven, and make a simple MAVEN instance and send it right away.

"Project management and Build"--maven download, install and configure (ii)

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.