Lnux(redhat 5.8)下 安裝jetty 部署 使用

來源:互聯網
上載者:User

標籤:des   blog   http   java   使用   os   檔案   io   

首先需要安裝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/testNote. If this file did not exist or used a context path other that /testthen the default configuration of jetty.xml would discover the testwebapplication with a WebAppDeployer.  By specifying a context in thisdirectory, 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的安裝及簡單使用就結束了!











聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.