方法一:使用Maven的plugin:jetty来部署项目
首先,在POM.xml中定位到<build></build>标签内的<plugins></plugins>标签,增加如下内容:
<!-- 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、右击项目 –> Run As –> Maven Build,双击打开Configuration Window
2、输入Base directory值-->选择项目
3、输入Goals值--jetty:run
4、User Setting配置文件
5、点击Apply按钮后, 点击Run按钮即可运行项目
方法二:使用Maven的plugin:tomcat来部署项目
首先,在POM.xml中定位到<build></build>标签内的<plugins></plugins>标签,增加如下内容:
<!-- 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、右击项目 –> Run As –> Maven Build,双击打开Configuration Window
2、输入Base directory值-->选择项目
3、输入Goals值--tomcat:run
4、User Setting配置文件
5、点击Apply按钮后, 点击Run按钮即可运行项目
方法三:使用Run on Server(Tomcat)部署项目
方法四:Eclipse->Help->Eclipse Marketplace->find Run-jetty-Run 安装,使用此插件也可以运行项目
本文介绍了使用Maven通过Jetty和Tomcat插件部署项目的详细步骤,并提到了使用RunonServer(Tomcat)及Run-jetty-Run插件进行部署的方法。
417

被折叠的 条评论
为什么被折叠?



