针对eclipse中的Run on Server有些情况下并不是那么好操作,比如配置maven下的springmvc插件,如果使用此方法运行会很容易出现组件缺少导致错误出现一大堆的问题。

那么针对这种情况,maven下的容器插件tomcat和jetty做了很好的支持。比如在maven下配置了这两个组件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
...
<build>
<finalName>testmvchelloworld</finalName>
<plugins>
<!-- Config: Maven Tomcat Plugin -->
<!-- http://mvnrepository.com/artifact/org.apache.tomcat.maven/tomcat7-maven-plugin -->
<!-- http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/plugin-info.html -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<!-- Config: contextPath and Port (Default:8080) -->
<!--
<configuration>
<path>/</path>
<port>8899</port>
</configuration>
-->
</plugin>
<!-- Config: Maven Jetty Plugin -->
<!-- http://mvnrepository.com/artifact/org.mortbay.jetty/jetty-maven-plugin -->
<!-- http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.3.v20170317</version>
<!-- Config: contextPath and Port (Default:8080) -->
<!--
<configuration>
<httpConnector>
<port>8899</port>
</httpConnector>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
</configuration>
-->
</plugin>
</plugins>
</build>
</project>

提示:如果想要带上引用名,可以在<contextPath>标签上加上/${project.artifactId}

那么在调试运行项目时,可以直接使用maven的命令直接进行:

//tomcat7
mvn tomcat7:run
//jetty
mvn jetty:run

其中控制台上输出的信息和本身Run on Server保持了一致。

Maven配置tomcat和jetty插件来运行项目的更多相关文章

  1. Maven 配置tomcat和findbug插件(在eclipse建立的项目中)

    tomcat插件 a)        tomcat的maven插件可以在tomcat的官网上寻找,这就是tomcat插件的plugin b)        将tomcat的plugin配置到项目的po ...

  2. Maven 配置tomcat插件

    使用tomcat插件来访问maven 1 先下载tomcat插件(在pom中配置) <!-- 配置Tomcat插件 --> <plugin> <groupId>or ...

  3. Maven -Maven配置tomcat插件 两种

    Maven Tomcat插件现在主要有两个版本,tomcat-maven-plugin和tomcat7-maven-plugin,使用方式基本相同. tomcat-maven-plugin 插件官网: ...

  4. JavaWeb学习之tomcat安装与运行、tomcat的目录结构、配置tomcat的管理用户、web项目目录、虚拟目录、虚拟主机(1)

    1.tomcat安装与运行双击tomcat目录下的bin/startup.bat,启动之后,输入http://localhost:8080,出现安装成功的提示,表示安装tomcat成功 2.tomca ...

  5. 配置 Tomcat 以服务方式自动运行

    接手一台用 Tomcat 跑着 Java Web 应用的 Linux CentOS 服务器,通过镜像的方式更换服务器后站点无法访问,发现是因为 Tomcat 不能在服务器启动后自动启动,于是基于 in ...

  6. Maven 配置Tomcat

    1.Tomcat conf 下的tomcat-users.xml 增加 <role rolename="manager"/> <role rolename=&qu ...

  7. Eclipse中使用Maven的Jetty插件Debug Web项目

    1.环境配置 JAVA_HOME=D:\Program Files\Java\jdk1.7.0_80 JRE_HOME=%JAVA_HOME%\jre CLASSPATH=.;%JAVA_HOME%/ ...

  8. maven学习四:maven集成jetty插件发布web项目 标签: maven

    http://blog.csdn.net/u014079773/article/details/50167833

  9. Eclipse 添加本地 SVN插件以及运行项目的流程

    去网上下载SVN插件包.里面包含文件如图: 把features和plugins文件夹里面的东西全部复制粘贴到eclipse安装目录下的features和plugins文件夹中就行.然后重启eclips ...

随机推荐

  1. 转:跟我一起写Makefile (PDF重制版)

    原文地址:http://seisman.info/how-to-write-makefile.html 其它一些问题  不妨看一下:http://blog.csdn.net/huyansoft/art ...

  2. stm32之ADC应用实例(单通道、多通道、基于DMA)

    文本仅做记录.. 硬件:STM32F103VCT6 开发工具:Keil uVision4 下载调试工具:ARM仿真器 网上资料很多,这里做一个详细的整合.(也不是很详细,但很通俗).  所用的芯片内嵌 ...

  3. uncaught exception 'NSInternalInconsistencyException, reason:[UITableViewController loadView] loaded the "Controller" nib but didn't get a UITableView

    http://blog.csdn.net/ryantang03/article/details/7941058#reply 上面那篇文章是我查找的ios实现下拉刷新功能,在我下载完代码运行的过程中发现 ...

  4. VMware-Ubuntu入门(1)

    大家都说Linux系统是让程序员用起来更有成就感的系统,我也来体验下: 对于小白鼠的我,并没有直接在电脑上重装Linux系统,而是通过VMware工具搭建Ubuntu虚拟linux环境. 首先展示下V ...

  5. Zend Framework 2中如何使用Service Manager

    end Framework 2 使用ServiceManager(简称SM)来实现控制反转(IoC).有很多资料介绍了service managers的背景,我推荐大家看看this blog post ...

  6. Educational Codeforces Round 34 (Rated for Div. 2)

    A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input sta ...

  7. HAZU校赛 Problem K: Deadline

    Problem K: Deadline Time Limit: 2 Sec Memory Limit: 1280 MB Submit: 1106 Solved: 117 [Submit][Status ...

  8. oracle dual表用途及结构详解

    dual是一个虚拟表,用来构成select的语法规则,oracle保证dual里面永远只有一条记录.我们可以用它来做很多事情,如下: 1.查看当前用户,可以在 SQL Plus中执行下面语句 sele ...

  9. 在Notepad++里配置python环境

    首先在语言里选择Python 然后点击运行,在弹出的对话框里输入: cmd /k cd /d "$(CURRENT_DIRECTORY)" &  python " ...

  10. iOS学习笔记40-日志重定向

    一.日志重定向 我们在iOS开发过程中,我们时常会使用NSLog打印到控制台的日志信息进行代码调试,但这样调试的前提是连接上Xcode.如果进行真机调试但同时又不能连接Xcode的时候,就不能直接在x ...