Jetty实战(杂七杂八)
最近开始选择JETTY作为服务器了,乘这现在空闲点学习了些JETTY的部署知识,原来她真的跟TOMCAT很类似,先总结如下:
部署应用方法(下载好jetty);
方法一:
直接将应用的 war包放在jetty_home/webapps下,启动jetty(命令:java -jar start.jar),默认jetty的端口是8080,在IE输入http://localhost:8080/jetty/jsp/login.jsp 即可。
方法二(动态部署):
1.拷贝jetty_home/contexts/test.xml到相同目录,更改名称为jetty.xml,修改改xml内容如下(红色标识部分):
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<!-- ==================================================================
Configure and deploy the test web application in $(jetty.home)/webapps/test
Note. If this file did not exist or used a context path other that /test
then the default configuration of jetty.xml would discover the test
webapplication with a WebAppDeployer. By specifying a context in this
directory, additional configuration may be specified and hot deployments
detected.
===================================================================== -->
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Required minimal context configuration : -->
<!-- + contextPath -->
<!-- + war OR resourceBase -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="contextPath">/jetty</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/jetty</Set>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Optional context configuration -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="extractWAR">false</Set>
<Set name="copyWebDir">false</Set>
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
<!-- <Set name="overrideDescriptor"><SystemProperty name="jetty.home" default="."/>/contexts/test.d/override-web.xml</Set>-->
<!-- virtual hosts
<Set name="virtualHosts">
<Array type="String">
<Item>www.myVirtualDomain.com</Item>
<Item>localhost</Item>
<Item>127.0.0.1</Item>
</Array>
</Set>
-->
<!-- disable cookies
<Get name="sessionHandler">
<Get name="sessionManager">
<Set name="usingCookies" type="boolean">false</Set>
</Get>
</Get>
-->
<Get name="securityHandler">
<Set name="userRealm">
<New class="org.mortbay.jetty.security.HashUserRealm">
<Set name="name">Test Realm</Set>
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
<!-- To enable reload of realm when properties change, uncomment the following lines -->
<!-- changing refreshInterval (in seconds) as desired -->
<!--
<Set name="refreshInterval">5</Set>
<Call name="start"></Call>
-->
</New>
</Set>
<Set name="checkWelcomeFiles">true</Set>
</Get>
<!-- Non standard error page mapping -->
<!--
<Get name="errorHandler">
<Call name="addErrorPage">
<Arg type="int">500</Arg>
<Arg type="int">599</Arg>
<Arg type="String">/dump/errorCodeRangeMapping</Arg>
</Call>
</Get>
-->
</Configure>

之后启动jetty即可完成部署。
<!-- jetty插件 -->
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
选择菜单Run->External Tools->External Tools Configurations ...在左边选择Program,再点New:
配置Location为mvn完整命令行。定位到bin下的mvn.bat
选择Working Directory为本项目。
Arguments填写:jetty:run

再点选Enviroment页:加入MAVEN_OPTS变量,值为:
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8088,server=y,suspend=y
其中,如果suspend=n 表示不调试,直接运行。address=8080为端口
然后,点APPLY,再点run已启动jetty.

另外注意一点,好像external tool菜单项在java browering的perspective下才会出现。如果在java下看不见,可以切换下试试。
2、调试应用
右键点击工程,选debug as ->debug configurations...

选中左树中的Remote Java Application,再点New。
选择你的项目,关键是要填和之前设置外部工具时相同的端口号。

点击apply,再点击degug即可。
Jetty实战(杂七杂八)的更多相关文章
- Jetty实战之 嵌入式Jetty运行Servlet
http://blog.csdn.net/kongxx/article/details/7230080 Jetty实战之 嵌入式Jetty运行Servlet 分类:JettyJava (19530) ...
- Jetty实战之 嵌入式Jetty运行web app
Jetty实战之 嵌入式Jetty运行web app 博客分类: 应用服务器 jettywar 转载地址:http://blog.csdn.net/kongxx/article/details/72 ...
- Jetty实战之 安装 运行 部署
本文地址:http://blog.csdn.net/kongxx/article/details/7218767 1. 首先从Jetty的官方网站http://wiki.eclipse.org/Jet ...
- (转)Jetty实战之 安装 运行 部署
http://blog.csdn.net/kongxx/article/details/7218767 本文地址:http://blog.csdn.NET/kongxx/article/details ...
- 第02篇. Jetty 9 实战之安装/运行/部署
一直以来,想改变一些自己早已经习惯的事情. 一直都听说jetty跟Tomcat一样,是一个web容器. 一直都是在说等等,再等等,等有时间的时候! 一直都是给自己一些逃避的理由 1. 首先从Jetty ...
- Jetty直接调试,不用部署,不用弄一些杂七杂八的设置
以前调试web程序的,搭建Tomcat实在是费劲,就想找一个比较简单的方式,我就想调试一下我写的某一个servlet形式,看到<how Tomcat works>这本书,才明白确实可以,不 ...
- Spark入门实战系列--2.Spark编译与部署(中)--Hadoop编译安装
[注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 .编译Hadooop 1.1 搭建环境 1.1.1 安装并设置maven 1. 下载mave ...
- Spark入门实战系列--6.SparkSQL(下)--Spark实战应用
[注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 .运行环境说明 1.1 硬软件环境 线程,主频2.2G,10G内存 l 虚拟软件:VMwa ...
- Spark入门实战系列--7.Spark Streaming(下)--实时流计算Spark Streaming实战
[注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 .实例演示 1.1 流数据模拟器 1.1.1 流数据说明 在实例演示中模拟实际情况,需要源源 ...
随机推荐
- Python模块化
在Python中,一个.py文件就称之为一个模块(Module). 模块化的好处: 1.大大提高了代码的可维护性. 2.编写代码不必从零开始.当一个模块编写完毕,就可以被其他地方引用.我们在编写程序的 ...
- APUE学习笔记——4.2结构体 struct stat 及其相关函数介绍
以下不少内容来自man手册 结构体struct stat 结构体struct stat用于保存文件相关的所有信息. struct stat的基本成员如下所示 struc ...
- jQuery 选择器效率
http://blog.csdn.net/cxl444905143/article/details/48808809 ID > Tag > Class ID 选择器是速度最快的,这主要是因 ...
- Android 贝塞尔曲线解析
相信很多同学都知道"贝塞尔曲线"这个词,我们在很多地方都能经常看到.利用"贝塞尔曲线"可以做出很多好看的UI效果,本篇博客就让我们一起学习"贝塞尔曲线 ...
- ARM寄存器总结:
ARM有16个32位的寄存器(r0到r15). r15充当程序寄存器PC,r14(link register)存储子程序的返回地址,r13存储的是堆栈地址. ARM有一个当前程序状态寄存器:CPSR. ...
- 【剑指offer】之字形打印二叉树,C++实现
原创文章,转载请注明出处! 本题牛客网地址 博客文章索引地址 博客文章中代码的github地址 1.题目 请实现一个函数按照之字形打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右至左的顺序打 ...
- librec库
固定初始化矩阵值 net.librec.math.structure -> class DenseMatrix -> void init()
- Linux下nginx安装与配置
部分Linux发布版的默认安装已经集成了nginx,查看方法ls /usr/local,若已有nginx文件夹说明已集成. nginx依赖库pcre与zlib,且pcre依赖于gcc与gcc-c++, ...
- erlang http post 发送数据请求
ibrowse:send_req("http://127.0.0.1/NativePhone.ashx", [{"Content-Type", "ap ...
- 64位ubuntu下Android开发环境的配置
本文介绍如何在64位ubuntu上搭建android的开发环境. 系统:ubuntu12.04LTS 使用的是ADT Bundle for Linux和jdk1.7(open jdk也可) 一共分为3 ...