温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Tomcat的Server Options选项详解

发布时间:2020-10-10 13:25:29 来源:脚本之家 阅读:325 作者:Developer 栏目:服务器

一、配置

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

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中就不存在这个节点了):

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

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

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI