Tomcat的Server Options选项详解

2025-05-26 0 57

一、配置

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

Tomcat的Server Options选项详解

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的Server Options选项详解

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

?

1

2

3

4

5

6

7

8
<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.

Tomcat的Server Options选项详解

优化

找到菜单,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)

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

原文链接:https://segmentfault.com/a/1190000006257159

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 Tomcat的Server Options选项详解 https://www.kuaiidc.com/54503.html

相关文章

发表评论
暂无评论