Tomcat的Server Options选项详解

发布时间:2022-04-24 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Tomcat的Server Options选项详解脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

一、配置

默认前两个是没有勾选的,应该勾选上:

1Server Options的第一个选项Serve modules wIThout publishing

在默认情况下,当项目部署到tomcat中,该插件会把项目文件拷贝到上一个配置项Server Locations中的显示Server pathwtpwebapps目录下,即当前wrokspace所在目录下的。metadata子目录中,如我的wrokspaceD:\workspace,那么该目录是:D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps

但如果选中上面的这个选项,则不会把项目文件发布到该目录下运行,而是:

web目录是:web项目的WebContent,即maven web项目的src/main/webapp目录

class文件目录是:是当前配置的class文件的输出目录,即maven项目的target/classes目录

2Timeouts

默认情况下start45秒,stop15秒,这里可能需要修改一下start为一个合适大的值,它的意思是当启动时间超过这里指定的时间还没有启动完成时,就报错。当我们的项目启动很耗时的情况下,这显然不是我们想要的,所以需要修改一下这个值。

勾选上Server Options->Serve Modules without publishing,不勾的话,修改类文件里就会不停的重启Web服务器;如果Web项目启动时间比较长的话,还需要修改超时时间,这个在Timeouts里面设置

在Cotext节点中有一个reloadable='true'属性,将它改为false,可以在修改java文件后不用重启服务器即可生效,但是不包括新建java文件、添加方法和变量的操作

二、浏览文件

Context节点单独生成的文件:

原来Tomcat安装目录下conf/server.XMl中的Context节点(勾选第二个选项之后,server.xML中就不存在这个节点了):

<Host appBase="webapps" autodeploy="true" name="localhost" unpackWARs="true">
  <Valve classname="org.apache.catalina.valves.AccessLOGValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" PRefix="localhost_access_log" suffix=".txt"/>
  <Context docBase="D:\workspace\workspace(eclipse)\Shop\WebContent" path="/Shop" reloadable="true" source="org.eclipse.jst.jee.server:Shop">
    <Resources>
      <PreResources base="D:\workspace\workspace(eclipse)\Shop\build\classes" classLoaderOnly="false" className="org.apache.catalina.webresources.DirResourceSet" internalPath="/" webAppmount="/WEB-iNF/classes"/>
    </Resources>
  </Context>
</Host>

三、原因

1.勾选第一个是为了止出现警告:

警告: A docBase D:/Tomcat/webapps/Shop inside the host appBase has been sPEcified, and will be ignored

勾选后表示让tomcat直接使用eclipse中的WebContent下的东西
省去publish到<workspace>.metadata.pluginsorg.eclipse.wst.server.coretmp0webapps
并将tmp0webapps下相关的resources删除,
同时会修改<workspace>.metadata.pluginsorg.eclipse.wst.server.coreservers.xml中的serveModulesWithoutPublish=true以及tmp0/conf/server.xml中的<Context>配置

2.勾选第二个是为了防止出现警告:

警 告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:strut2demo' did not find a matching property.

[SetPropertiesRule]警告的原因是Tomcat6.0以上的server.xml的context节点中不再支持source属性了。具体说明如下:

For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place <Context> elements directly in the server.xml file. This is because it makes modifying the Context configuration more invasive since the main conf/server.xml file cannot be reloaded without restarting Tomcat.

优化

找到菜单,Window->Preferences

检查英文的拼写没什么用处,这里把拼写检查取消,位置:General->Editors->Text Editors->Spelling,把Enable spell checking 取消勾选

还有一处的检查也可以取消 位置:Validation,勾选Suspend all validators

显示行号 位置:General->Editors->Text Editors,勾选Show line numbers

jsp页面的默认编码方式改为utf-8 位置:Web->JSP FilesEncoding改为ISO 10646/Unicode(UTF-8)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本宝典。

脚本宝典总结

以上是脚本宝典为你收集整理的Tomcat的Server Options选项详解全部内容,希望文章能够帮你解决Tomcat的Server Options选项详解所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:ServerTomcat