你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux(RedHat 5.8)下 安装Jetty 部署 使用

[日期:2014-10-23] 来源:Linux社区  作者:simonchi [字体: ]

Linux(RedHat 5.8)下 安装Jetty 部署 使用

首先需要安装JDK,自行解决

下载jetty安装包http://dist.codehaus.org/jetty/

我下载的是8.1.15

tar -xzvf *.tar.gz

解压完之后,基本就可以用了

webapps下有一些demo的war包

启动jetty服务:java -jar start.jar  默认端口8080

访问http://localhost:8080就可以了

现在开始部署你自己的war包

加入你的war包已经有了,名字是abc.war

那么将该war包放到webapps下面

重新启动jetty

访问http://localhost:8080/abc即可访问

如果你的war包名字很复杂不想修改,但是访问路径时希望简单

你可以复制context目录下的test.xml为XXX.xml 然后修改该文件内容

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/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.eclipse.jetty.webapp.WebAppContext">

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Required minimal context configuration :                        -->
  <!--  + contextPath                                                  -->
  <!--  + war OR resourceBase                                          -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="contextPath">/hello</Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/abc-123-def-567.war</Set>

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Optional context configuration                                  -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="extractWAR">true</Set>
  <Set name="copyWebDir">false</Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.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>
  -->

 
 
  <!-- 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>
  -->

  <!-- Add context specific logger
  <Set name="handler">
    <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
      <Set name="requestLog">
 <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
  <Set name="filename"><Property name="jetty.logs" default="./logs"/>/test-yyyy_mm_dd.request.log</Set>
  <Set name="filenameDateFormat">yyyy_MM_dd</Set>
  <Set name="append">true</Set>
  <Set name="LogTimeZone">GMT</Set>
 </New>
      </Set>
    </New>
  </Set>
  -->

</Configure>

这时候你可以看到war包名字很复杂,但是访问的路径已经修改为hello了

所以现在重新启动jetty服务,访问http://localhost:8080/hello即可访问了

至此jetty的安装及简单使用就结束了!

使用Jetty作为嵌入式服务器 http://www.linuxidc.com/Linux/2013-07/86983.htm

Jetty 源码分析 http://www.linuxidc.com/Linux/2013-10/90986.htm

Jetty安装学习并展示 http://www.linuxidc.com/Linux/2014-05/101993.htm

Jetty在Eclipse中的安装 http://www.linuxidc.com/Linux/2013-10/90991.htm

更多RedHat相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10

本文永久更新链接地址http://www.linuxidc.com/Linux/2014-10/108342.htm

linux
相关资讯       Jetty 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款