Maven2 creates a web project and does not have a solution to run on server using eclipse.

Source: Internet
Author: User

It is annoying to have a problem. When using maven2 to build a web project, there is no run on server option. After Google, I saw a post written by an iteye elder brother and tried it. Bingo is really easy to use.

 

Address: http://celestialwolf.iteye.com/blog/720303#comments

 

 

Maven is easy to learn. It records the basic knowledge of Maven to meet your needs.

Common commands:

MVN archetype: Create a Maven Project

MVN compile: Compile source code

MVN test-compile: Compile the test code

MVN test: run the unit test in the application.

MVN site: the website that generates project-related information

MVN clean: clears the generated results in the target directory.

MVN package: generate a jar file based on the project

MVN install: Install jar in local repository

MVN deploy: publish the jar package to a remote repository.

MVN Eclipse: generate an Eclipse project file

Generate a project

Create a Java project: MVN archetype: Create-dgroupid = com. Test-dartifactid = app

Create a WEB Project: MVN archetype: Create-dgroupid = com. Test-dartifactid = web-app-darchetypeartifactid = Maven-Archetype-webapp

Explanation:

Archetype is a built-in plug-in. Its Create task will create a Project Skeleton.

Type of the archetypeartifactid Project Skeleton

The Java Package Structure of the groupid project. You can modify the name of the artifactid project. The generated project directory is also the name, which can be modified.

Available Project Skeleton:

Maven-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 an existing Maven project:

Before importing data, run the following command in the project root directory:

Normal Eclipse project execution: MVN Eclipse: Eclipse eclipse

Web project execution: MVN Eclipse: eclipse-dwtpversion = 1.0

Use the maven plug-in of eclipse to import existing Maven projects.

Problems in the learning process:

After installing the m2eclipse plug-in, an error is reported: Eclipse is running in a JRE, but a JDK is required some Maven plugins may not work when importing projects or updating source folders.

Solution:

1. Create an eclipse startup shortcut and add-VM to your JDK installation path/bin/javaw.exe after the startup path.

2. Open the-vmargs in eclipse. ini under the eclipse installation directory and add-VM your JDK installation path/bin/javaw.exe

Web project created by ECLIPSE Import

When importing a web project using eclipse, if the WTP plug-in is installed in eclipse, it is automatically converted to a web project recognized by eclipse, right-click the run on server of run as in the project, but run on server is not required when the WTP plug-in is not installed in eclipse, the solution is to use the command line to switch to the root directory of the project and 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.