---
title: "在Eclipse中部署Maven项目的几种方法"
author: "HogwartsRow"
date: "2016-04-11T16:10:24Z"
tags: []
categories: ["编程语言"]
slug: "eclipse-maven"
draft: false
lastmod: "2017-04-26T14:48:21Z"
id: 2290033
url: "https://hogwartsrow.iteye.com/blog/2290033"
---

方法一：使用Maven的plugin:jetty来部署项目

首先，在POM.xml中定位到&lt;build&gt;&lt;/build&gt;标签内的&lt;plugins&gt;&lt;/plugins&gt;标签，增加如下内容：

 

```
<!-- Maven JettyPlugin -->
<plugin>
	<groupId>org.mortbay.jetty</groupId>
	<artifactId>jetty-maven-plugin</artifactId>
	<version>8.1.2.v20120308</version>
	<configuration>		
	        <webAppConfig>
		        <defaultsDescriptor>${basedir}/src/main/resources/webdefault.xml</defaultsDescriptor>
	        </webAppConfig>
	</configuration>
</plugin>
```

 

 

其次，配置Maven Build窗口参数：1、右击项目 –&gt; Run As –&gt; Maven Build，双击打开Configuration Window

2、输入Base directory值--&gt;选择项目

3、输入Goals值--jetty:run

4、User Setting配置文件

5、点击Apply按钮后， 点击Run按钮即可运行项目

 

方法二：使用Maven的plugin:tomcat来部署项目

首先，在POM.xml中定位到&lt;build&gt;&lt;/build&gt;标签内的&lt;plugins&gt;&lt;/plugins&gt;标签，增加如下内容：

```
<!-- Maven Tomcat Plugin -->
<plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>tomcat-maven-plugin</artifactId>
	<version>1.1</version>
	<configuration>
	<path>/sample</path>
	<port>8080</port>
	<uriEncoding>UTF-8</uriEncoding>
	<server>tomcat6</server>
	</configuration>
</plugin>
```

 其次，配置Maven Build窗口参数：1、右击项目 –&gt; Run As –&gt; Maven Build，双击打开Configuration Window

 

2、输入Base directory值--&gt;选择项目

3、输入Goals值--tomcat:run

4、User Setting配置文件

5、点击Apply按钮后， 点击Run按钮即可运行项目

 

方法三：使用Run on Server（Tomcat）部署项目

 

方法四：Eclipse-&gt;Help-&gt;Eclipse Marketplace-&gt;find Run-jetty-Run 安装，使用此插件也可以运行项目