MyEclipse maven Tomcat plugin create Web project

Source: Internet
Author: User

Since the cloud notes, a long time not to write blog. Today wrote the use of Freemarker static JSP page, simply sent out. Beginner, do not spray.

This text was previously placed in the cloud notes, of course, there is a lot of reference to the network of things, and they also use Maven for a long time, simply send out together.

  

myeclipse6.5 build MAVEN Environment One, MyEclipse 6.5 comes with Maven plugin, not good. First uninstall the included Maven plugin. By searching maven in \myeclipse 6.5\myeclipse\eclipse, all Files (folders) with Maven are deleted. Second, then install the plugin in Myeclipse6.5 's Help menu, the plugin address is: http://repository.sonatype.org/content/sites/forge-sites/m2e/0.10.0/S/20100209-0800/

After the Maven plugin is installed, you can see a maven option on the left side of the MyEclipse window-Preferences window, such as

:

We need to add an external maven, that is, the MAVEN installed on your machine, click Installations, select the Add button on the right, and choose Maven installed on your machine, such as:

Then click on User Settings, set the user Settings, select%maven_home%\conf\settings.xml, and set local repository as the repository, which is the path set in Settings.xml. Such as:

          

After setting this step, find M2_repo,edit in Window-->preferences-->java-->build path-->classpath variables, Edit path to your local repository (if it is already a local repository, do not edit it).

(An error may be reported here,

1: Open eclipse Click on ' Window ', ' Preferences ', ' Java ', ' Installed JREs '.

If you can ' t find any JDK on the list, click ' Add ', ' Standard VM ', set all paths and click ' Finish '.

After That–check this JDK is on the list of installed JREs and click ' OK '.

2: Locate the Eclipse.ini file in the installation directory of Eclipse to edit this file

Add the above parameter to the-vmargs

-vm
D:\Java\jdk1.5.0_08\bin

Two lines, some people say the JDK can not use 1.7, I tried no problem;

At this point, Eclipse+maven's development environment has been all set up, can start to establish a project development.

Tomcat Plugin

Add the following XML to the POM.XM.

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<path>/wp</path>
<port>8080</port>
<uriEncoding>UTF-8</uriEncoding>
<url>http://localhost:8080/manager/html</url>
<server>tomcat6</server>
</configuration>
</plugin>

  

Briefly describe:

Path is the way to access the app

Port is the port number of Tomcat

Uriencoding URL by UTF-8 encoding, this solves the Chinese parameter garbled.

The Server specifies the tomcat name.

The configuration is so simple, basically fixed, below to see how to use.

Note: After booting, Tomcat will first load the jar under its own lib, and if there are repeated errors in the project, change the scope of the corresponding dependency under Pom.xml to provided

Plugin Run

If eclipse installs the Maven plugin, select the Pom.xml file, right-click and select Run as--> maven build.

If this is the first time, the following dialog box will pop up. Add the following command to the Goals box: Tomcat:run

This will allow the Tomcat plug-in to run.

Here are a few common goal

Command Describe
Tomcat:deploy Deploy a Web War package
Tomcat:reload Reload the Web War package

Tomcat:start

Start Tomcat

Tomcat:stop

Stop Tomcat

Tomcat:undeploy

Stop a war package
Tomcat:run Start embedded Tomcat and run the current project
Tomcat7-maven-plugin using Configuration

Two plug-ins using the same method, the same need to reference the plug-in pom.xml, need to add the following configuration

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<port>9090</port>
<path>/mgr</path>
<uriEncoding>UTF-8</uriEncoding>
<finalName>mgr</finalName>
<server>tomcat7</server>
</configuration>
</plugin>

  

The exact same configuration.

Plug-in use

Note here that the plug-in naming method is somewhat different, such as the launch of Tomcat, the corresponding target command is: Tomcat7:run, similarly, the other command is the same, need to change to:tomcat7:< plug-in Execution point >

Maven Error

When using the Maven plugin in Eclipse, error when running run as MAVEN build

-dmaven.multimoduleprojectdirectory system propery is not set. Check $M 2_home environment variable and MVN script match.

Straightforward workaround: Use a lower version of Maven

You can set up an environment variable m2_home point to your MAVEN installation directory

m2_home=d:\apps\apache-maven-3.3.1

And then in window->preference->java->installed Jres->edit

Set in default VM arguments

-dmaven.multimoduleprojectdirectory= $M 2_home

MyEclipse maven Tomcat plugin create Web project

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.