Installing MAVEN on Windows

Source: Internet
Author: User
Tags jboss

MAVEN's specific reference books can be seen: "Maven combat"

Download maven to: http://maven.apache.org/

The basic use of Maven for Eclipse can be seen here: http://www.iteye.com/topic/1123225

1. Unzip the downloaded Maven zip file to a place like this: f:\tool\apache-maven-3.2.5

2, set environment variables (similar java_home):

Add a new "MAVEN":

Add "MAVEN" to Path:

%maven%\bin

3. Open the command line to see if MAVEN is configured correctly:

Open cmd window: Enter Mvn-version, the following appears to indicate the successful installation.

4. Generate Maven local repository. In a MAVEN project, the user does not need to download the dependent jar package and put it into the project as before, only need to define the project's Pom.xml file, and maven will automatically download the corresponding package from the network to the local warehouse when using the MAVEN command on the project, and the project can use the package of the local warehouse directly. When you install Maven for the first time, enter the MVN help:system command in the Windows Command Prompt window and then enter, and then you can see some of the files that Maven downloaded in C:\Users\Admin\.m2\repository after it finishes executing.

MVN Help:system

Operation Result:

When this command finishes running, a ". M2" folder will be automatically generated in the Windows user folder with a repository directory, such as:

C:\Users\Admin\.m2

This is the local user repository, which will be downloaded in the future with a jar package that is automatically downloaded using MAVEN.

Note: user-defined local repositories

The MAVEN repository defaults to the. M2 folder under the local user's Temp folder under Repository, mine is under the C:\Users\Admin\.m2\repository directory,

Now let's modify to assign it to our own path, I'm now going to assign the warehouse to the D:\Repositories\Maven directory,

Find Maven's storage directory (or installation directory) Open the Settings.xml file under the Conf folder, find the 53rd line, remove the comment, and modify it to:

<localRepository> d:\repositories\maven</localrepository>

Knock in CMD and enter to execute: MVN help:system this time maven will download a whole bunch of things from the remote repository, sooner or later,

Note: Use a user-level MAVEN configuration

MAVEN has a global profile for the MAVEN root directory/conf/settings.xml file (for example, mine is C:\tools\apache-maven-3.2.5\conf\ settings.xml), MAVEN uses this configuration file by default, and all users share this configuration. However, it is recommended that each user configure their own profile to prevent the non-impact of other users in the system, simply copy the global configuration file to the. M2 folder in the user directory (my current user is Admin, so copy is C:\Users\Admin\.m2\ settings.xml). (If you do not have a. M2 folder, go to the previous step, and Maven generates the. M2 folder in the current user's directory.)

Note: Installing the MAVEN plugin in eclipse

Plugin name: M2eclipse, in the Eclipse menu bar, select Help--Install New software, you will see an Install dialog box, click the Add button, enter M2E in the Name field, Enter HTTP://M2ECLIPSE.SONATYPE.ORG/SITES/M2E in the Location field, click Ok,eclipse to download the resource information on the Meeclipse installation site, wait for the resource to be loaded and follow the prompts to install it

Eclipse typically integrates this plug-in with an inline maven

5. Eclipse Configuration maven:

Click Window->perference->maven->installations in eclipse to set up your own download of Maven.

The original eclipse-brought Maven can be removed because most versions are not the same, leading to inexplicable problems later.

6. New Maven Web project method:

6.1) Ctrl + N:

In this way, a MAVEN Web project has been built. However, by default, the Java version in the Project facet is 1.5, and you want to modify it to the local Java version.

6.2) Right-click the project->properties and change it to:

I'm using JBoss here, so I'm going to set the runtimes in the dynamic Web module to JBoss:

6.2) Create a new Src/main/java source folder with Maven's default contract:

This folder needs to be built manually, and cannot be built in the new source folder mode. (If the new hint already exists, but in fact not, just select your own JDK version in BuildPath.)

6.3) Open Pom.xml file, join dependency (dependency)

<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > <modelversion >4.0.0</modelVersion> <groupId>com.my.mavenweb</groupId> <artifactid>testweb1</ artifactid> <packaging>war</packaging> <version>0.0.1</version> <name>testweb1 Maven webapp</name> <url>http://maven.apache.org</url> <properties> <springframework.v Ersion>3.2.0.release</springframework.version> <freemarker.version>2.3.20</freemarker.version > <modelmapper.version>0.7.2</modelmapper.version> </properties> <dependencies> &lt ;d ependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version    >3.8.1</version> <scope>test</scope></dependency> <dependency> <groupId>org.springframework</groupId> <artifactid&    Gt;spring-core</artifactid> <version>${springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactid>spring-beans</ artifactid> <version>${springframework.version}</version> </dependency> &LT;DEPENDENCY&G        T <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version&gt ;${freemarker.version}</version> </dependency> <dependency> <groupid>org.modelmapper& Lt;/groupid> <artifactId>modelmapper</artifactId> <version>${modelmapper.version}</v  ersion> </dependency> </dependencies> <build> <finalName>testweb1</finalName> </build></project> 

For example I added a few dependencies: Spring, Freemarker, Modelmapper.

Save Pom.xml,eclipse will automatically go to the central server to download the corresponding jar package, jar package saved in the user folder./m2

Here, Maven's eclipse configuration is basically complete.

7. Build and build Maven

Right-click Project->run as->maven Install in eclipse

Maven defaults to placing the generated war file, class-compiled files in the target directory in the project folder

Ii. errors you may encounter when installing the Maven plugin in Eclipse: original link 1, original link 21. When installing M2eclipse, how to solve this kind of error? Please see the error for more information.
Issue : Cannot complete the install because one or more required items could not be found.

Software being Installed:maven integration for Eclipse (Required) 0.12.1.20110112-1712 (or
G.maven.ide.eclipse.feature.feature.group 0.12.1.20110112-1712)

Missing requirement:maven Project Model Edit Bundle 0.12.1.20110112-1712 (org.maven.id
E.eclipse.maven_model_edit 0.12.1.20110112-1712) requires ' bundle Org.eclipse.emf.ecore 0.
0.0 ' But it could wasn't be found

Cannot satisfy dependency:

From:maven Integration for Eclipse (Required) 0.12.1.20110112-1712 (org.maven.ide.eclip
Se.feature.feature.group 0.12.1.20110112-1712)

To:org.maven.ide.eclipse.maven_model_edit [0.12.1.20110112-1712] He said there was a file that couldn't be found.
。 But in the link to Maven's m2e, the relevant files are there. Tried a lot of times. All have this problem.
Workaround: connect Helios Update site (helios-http://download.eclipse.org/releases/helios) First, install
Plugin graphical Editing Framework Zest visualization Toolkit SDK. Then install M2eclipse plug-ins.
2: If the installed plug-in version is too high will be reported
Cannot complete the install because one or more required items could not be  found.    Software being installed: m2e - Maven Integration for Eclipse (includes I   ncubating components) 1.5.0.20140606-0033 (org.eclipse.m2e.feature.feature.   group 1.5.0.20140606-0033)    Missing requirement: Maven Integration for Eclipse 1.5.0.20140606-0033 (o   rg.eclipse.m2e.core 1.5.0.20140606-0033) requires ‘bundle com.google.guava    [14.0.1,16.0.0)‘ but it could not be found      Cannot satisfy dependency:        From: Maven Integration for Eclipse 1.5.0.20140606-0033 (org.eclipse.m2   e.core.ui 1.5.0.20140606-0033)        To: bundle org.eclipse.m2e.core [1.5.0,1.6.0)      Cannot satisfy dependency:        From: m2e - Maven Integration for Eclipse (includes Incubating componen   ts) 1.5.0.20140606-0033 (org.eclipse.m2e.feature.feature.group 1.5.0.201406   06-0033)   答案:这种情况换一个低版本的安装,如  http://download.eclipse.org/technology/m2e/milestones/1.4

Installing MAVEN on Windows

Related Article

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.