Maven and Eclipse combine to create a Web project __web

Source: Internet
Author: User
As a beginner, Maven feels its power of convenience, documenting MAVEN's basic knowledge for a rainy future.

Common commands are:

MVN archetype:create: Creating a Maven Project

MVN compile: Compiling source code

MVN test-compile: Compiling test code

MVN test: Running unit tests in the application

MVN site: Sites that generate project-related information

MVN clean: Clears the build results from the target directory

MVN package: Generate Jar files from project

MVN install: Installing the jar in the local Repository

MVN deploy: Publish a jar package to a remote repository

MVN eclipse:eclipse: Generate Eclipse Project file

Build Project

Build a JAVA project: MVN Archetype:create-dgroupid=com.test-dartifactid=app

Build a Web project: MVN Archetype:create-dgroupid=com.test-dartifactid=web-app-darchetypeartifactid=maven-archetype-webapp

Explain:

Archetype is a built-in plugin that creates a project skeleton for its create task

Archetypeartifactid type of Project skeleton

GroupId Project Java package structure, you can modify the name of the Artifactid project, the resulting project directory is also the name, can be modified

The available project skeletons are:

Maven-archetype-archetype

Maven-archetype-j2ee-simple

Maven-archetype-mojo

Maven-archetype-portlet

Maven-archetype-profiles (currently under development)

Maven-archetype-quickstart

Maven-archetype-simple (currently under development)

Maven-archetype-site

Maven-archetype-site-simple

Maven-archetype-webapp

Layout of the Web project directory structure:

See http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

Eclipse imports a Maven project that already exists:

Before importing, you need to execute the following command under the project root directory:

Common Eclipse Project execution: mvn eclipse:eclipse eclipse

Web project execution: mvn eclipse:eclipse–dwtpversion=1.0

You can then import the existing MAVEN project by selecting it from the Maven plugin for Eclipse.

Problems in the learning process:

After installing the M2eclipse plug-in, it is common to report an error: Eclipse is running in a JRE, but a JDK was required Some Maven plugins may isn't work when importing PR Ojects or updating source folders.

The solution is as follows:

1. Create an Eclipse startup shortcut and add-VM to your JDK installation path after its boot path \bin\javaw.exe

2. In the installation directory of Eclipse, open the-vmargs in Eclipse.ini to add-VM to your JDK installation path \bin\javaw.exe

Web project issues created by Eclipse Import

When you import a Web project with Eclipse, if Eclipse installs a WTP plugin that will automatically convert it to an Eclipse-recognized Web project, right-click Run as on the project can be used, However, when Eclipse does not have the WTP plugin installed, run on server does not, and the workaround is to use the command line to switch to the root of the project and then execute MVN eclipse:eclipse–dwtpversion=1.0.

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.