Overview
- 在tomcat 5.5之前,Context體現在/conf/server.xml中的Host里的
元素,它由Context接口定義。 - 每個Context元素代表了運行在虛擬主機上的單個Web應用。
- 在tomcat 5.5之后,不推薦在server.xml中進行配置,而是在/conf/context.xml中進行獨立的配置。因為server.xml是不可動態重加載的資源,服務器一旦啟動了以后,要修改這個文件,就得重啟服務器才能重新加載。而context.xml文件則不然,tomcat服務器會定時去掃描這個文件。一旦發現文件被修改(時間戳改變了),就會自動重新加載這個文件,而不需要重啟服務器。
Configuration
啟動告警
07-Mar-2017 11:28:00.620 WARNING [RMI TCP Connection(2)-127.0.0.1]
org.apache.catalina.webresources.Cache.getResource Unable to add the resource at
[/WEB-INF/classes/org/hibernate/jpa/orm_2_1.xsd]
to the cache because there was insufficient free space available after evicting expired cache entries -
consider increasing the maximum size of the cache
<!-- 直接關閉緩存 -->
<Resources cachingAllowed="false" />
<!-- 緩存的配置默認是開啟的,大小是10240KB,這里配置成100M(單位是KB) -->
<Resources cachingAllowed="true" cacheMaxSize="102400"/>
cachingAllowed - 是否允許啟用靜態資源(HTML、圖片、聲音等)的緩存。默認值為true。
cacheMaxSize - 設置靜態資源緩存的最大值,單位為K。
Reference
https://tomcat.apache.org/tomcat-9.0-doc/config/resources.html