MAVEN (1)------build MAVEN projects with MyEclipse

Source: Internet
Author: User
Tags object model
One

MAVEN Official website: http://maven.apache.org/

According to the official website, MAVEN is an open source project management tool written in Java, based on a concept called the Project object Model (POM) that can manage the life cycle of a project, from build to release to document management.

Here are the steps I built:

1. Install Maven

A. Go to the official website to download the latest MAVEN, unzip, directory structure as follows

B. Configure environment variables (this is the main purpose in order to use command-line operations under Windows, if you just want to build maven with MyEclipse, you can skip this step)

Once configured, you can enter mvn-version on the command line to see if the configuration is successful, and if the following interface appears, the configuration is successful.

2. Configure Maven in MyEclipse

Open the menu in MyEclipse windows->preferences-> search "maven", find "Installations", add the Maven directory just now, tick And then introduce your maven settings.xml file. As shown in figure

3. Configure the local repository for MAVEN.

One of the benefits of using MAVEN to build a project is to simply declare which jar packages are being introduced, and MAVEN will automatically download the dependent jar package at the first boot, down to the local. The address of this local warehouse is configured in the previous step mentioned in the Settings.xml file, in which the following sentence is configured [HTML] view plain copy print? <localRepository>F:\\mavenfiles</localRepository>

At this point, the MAVEN configuration is a success, and here's how to use Maven.


4. Create a project

The first way: New->other-> search "maven" and double-click Maven Project. Then select the project name and location, default is the current workspace, direct Next

Because the building is generally a Web project, so the directory select all, input webapp filter, find Maven-webapp,next. As follows

,

Enter the appropriate group ID and Ariface ID and click Done.

The second way:

Create a new Web project and, with the functionality provided by MyEclipse at the time of new, tick maven support-"ADD maven supports" and next down.

The final directory structure is as follows

If you are using Maven for the first time (and of course later, if the project depends on a jar that does not exist in your local repository), select the newly created project, right-->debug->dubug configuration

Enter the package command and click "Debug" to start downloading the relevant jar, which will be available when he has finished downloading.


Then deploy to Tomcat like a normal Web project, then launch and Access index.jsp, as follows.


At this point, MAVEN builds the project successfully. The next article will talk about some of MAVEN's configuration and core things, such as Pom.xml.
two

To install Maven:
Determine if the JDK is already installed.
Download maven
Address: http://maven.apache.org/download.html
Version: maven3.0.*


To configure MAVEN:
Check for JDK installation (jdk6.0+)
Java-version Echo%java_home%
Unzip the downloaded Apache-maven-3.0*-bin.zip (unzip to the best not to have Chinese or with spaces in the directory)
Configure system Environment variables: Maven_home points to the directory after MAVEN decompression
Configure Path=%maven_home%\bin
Authentication: DOS Prompt input: mvn-v

I am using the Maven version:

After installing MAVEN, MyEclipse10 comes with Maven plugin, only need to configure it can be used, Eclipse installs Maven plugin, there is time to fill in later:

After the application, do not click OK, the following image, just beginning, this path is no settings.xml configuration file, you need to/conf from the installation of the MAVEN directory under the settings.xml to the directory below, for example, I will d:\ Apache-maven-3.0.4\conf\settings.xml copied to the directory below. The file when Maven global configuration file, maven directory settings.xml for Global, and the following figure is configured, For the current user. Changing the global is not recommended and changing the current user's profile

--------------------------------------------------------------------------------------------------------------- -------------------------------------------------

To build a MAVEN project:

Point to the next step, and then encounter an error:

There are two ways to solve the problem online:

1. In the previous step, tick create a simple (skip archetype selection)

2. In the installation directory of Eclipse, locate the Eclipse.ini in this file to allocate more eclipse memory you are encountering an error that is not enough memory. Configuration parameters can be consulted: http://www.cnblogs.com/mingforyou/archive/2012/03/03/2378143.html

The first kind should be possible, because directly skip the retrieval process, I experimented with the second, also can, changed the configuration file:

After the problem is resolved, go ahead and leave the default to:

Note: If you are building a Web project, use:

Remove the two classes from your own:

Find a jar package using MAVEN, such as JUnit:

To perform the Maven cleanup command using the MAVEN component:

To execute the MAVEN Package command:

To perform a Maven installation, publish to the local Warehouse command:


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.