Linux(RedHat 5.8)下 安装Jetty 部署 使用
首先需要安装JDK,自行解决
下载jetty安装包
我下载的是8.1.15
tar -xzvf *.tar.gz
解压完之后,基本就可以用了
webapps下有一些demo的war包
启动jetty服务:java -jar start.jar 默认端口8080
访问:8080就可以了
现在开始部署你自己的war包
加入你的war包已经有了,名字是abc.war
那么将该war包放到webapps下面
重新启动jetty
访问: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 /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>
<!– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –> <!– Required minimal context configuration : –> <!– + contextPath –> <!– + war OR resourceBase –> <!– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –> <Set>/hello</Set> <Set><SystemProperty default=”.”/>/webapps/abc-123-def-567.war</Set>
<!– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –> <!– Optional context configuration –> <!– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –> <Set>true</Set> <Set>false</Set> <Set><SystemProperty default=”.”/>/etc/webdefault.xml</Set> <!– virtual hosts <Set> <Array type=”String”> <Item></Item> <Item>localhost</Item> <Item>127.0.0.1</Item> </Array> </Set> –>
<!– disable cookies <Get> <Get> <Set type=”boolean”>false</Set> </Get> </Get> –>
<!– Non standard error page mapping –> <!– <Get> <Call> <Arg type=”int”>500</Arg> <Arg type=”int”>599</Arg> <Arg type=”String”>/dump/errorCodeRangeMapping</Arg> </Call> </Get> –>
<!– Add context specific logger <Set> <New> <Set><New> <Set><Property default=”./logs”/>/test-yyyy_mm_dd.request.log</Set> <Set>yyyy_MM_dd</Set> <Set>true</Set> <Set>GMT</Set></New> </Set> </New> </Set> –>
</Configure>
这时候你可以看到war包名字很复杂,但是访问的路径已经修改为hello了
所以现在重新启动jetty服务,,访问:8080/hello即可访问了
至此jetty的安装及简单使用就结束了!
使用Jetty作为嵌入式服务器
Jetty 源码分析
Jetty安装学习并展示
Jetty在Eclipse中的安装
本文永久更新链接地址:
遇见你,是我一生的幸运;爱上你,