Apply MAVEN to create MAVEN project in Eclipse

Source: Internet
Author: User

We have completed MAVEN installation and configuration, JDK installation and configuration

Next, actually create the MAVEN type project in eclipse

First, Eclipse "File"-"new"-"other ... "--" Mave "-" Maven Project "

Group ID: Package Name

Artifact Id: Project name

When you click Done

Ii. setting up Maven vs. JDK versions

1. If the JDK7 version is installed on the machine, set the JDK version to 1.7 in project

Select the MAVEN project created above, right-click Properties, Java Build Path,

See Right Libraries tab page, JRE System Library item, default to 1.5 version, remove first, then add Library, select 1.7

Iii. need to match the Web App version to the JDK version

The project we created is a web app type, note that the Web App version corresponds to the JDK, and if the version does not correspond, it will be an error

For example, WebApp version 2.3 default corresponds to jdk1.5

WebApp version 2.5 corresponds to jdk1.7

Now that the jdk1.7 is installed, it is time to change the relevant configuration, mainly in several configuration files

1. Web. xml

Open the Web. xml file in current project

2. Find the Settings.xml file

If none of the following is in the file, add the following:

<profile>

<id>jdk-1.7</id>

<activation>

<activeByDefault>true</activeByDefault>

<jdk>1.7</jdk>

</activation>

<properties>

<maven.compiler.source>1.7</maven.compiler.source>

<maven.compiler.target>1.7</maven.compiler.target>

<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>

</properties>

</profile>

3. Locate the settings directory in the directory where the current MAVEN project is located

Switch

Switch

Switch

Iv. Apply the MAVEN plugin to new project and convert to Java project

1. Install Maven Plugin

Generate a Maven project with template tools, such as the simplest Maven-archetype-quikstart plugin

Plug - ins:

http://maven.ibiblio.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/

Or

Http://repo.maven.apache.org/maven2/org/apache/maven/plugins

Or

http://maven.oschina.net/content/groups/public/org/apache/maven/archetypes/maven-archetype-quickstart/(sometimes not open)

Another command-line installation

Into the cmd window:

MVN install:install–file-dgroupid=org.apache.maven.archetypes-dartifactid=maven–archetype-quickstart-dversion= 1.1-dpackaging=jar-dfile=maven-archetype-quickstart-1.1.jar

If you do not install this plugin, you will get an error when creating a new Maven project in Eclipse:

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:release from any of the configured Repositories.
Could not resolve artifact

Workaround: Load the Maven-archetype-quickstart in the local library

2. How to convert it into a MAVEN-generated directory structure converted to eclipse-supported Java project

    • Navigate to the Maven root directory, which has the Pom.xml file
    • Using the MAVEN command:

MVN Clean:clean [clears build results in target directory]
MVN eclipse:eclipse [Generate Eclipse Project file and package reference definition]

    • After executing it into the root directory, we will find two files generated:. Classpath and. Project
    • Open the project import above in eclipse

V. Update Project

Select the MAVEN project, update the externally dependent jar package, right-click "maven"? " Update Project ... "

After the refresh, the directory structure, such as

Vi. Check that the version configuration is complete.

If there is a problem, you can check the above steps

Vii. Configuration of POM files

The jar package-related properties referenced in the project configured in Pom.xml, if a new jar is required to be referenced and added,

You can query Groupid,artifactid with http://search.maven.org/and then configure it in Pom.xml

Querying the JAR package page

In the Pom.xml file header, you can define a properties that defines the version number for each package

Configure package by Type

Apply MAVEN to create MAVEN project in Eclipse

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.