- 使用Apache Tomcat/8.5.32部署运行flowable-6.5.0时发现控制台有警告
- 问题原因:
- 解决方法:
使用Apache Tomcat/8.5.32部署运行flowable-6.5.0时发现控制台有警告
01-Apr-2024 20:55:08.877 警告 [localhost-startStop-1] org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [/WEB-INF/classes/static/bower_components/sass-bootstrap/examples/screenshots/offcanvas.jpg] to the cache for web application [/flowable-admin] because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
01-Apr-2024 20:55:08.878 警告 [localhost-startStop-1] org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [/WEB-INF/classes/static/bower_components/sass-bootstrap/examples/screenshots/sticky-footer-navbar.jpg] to the cache for web application [/flowable-admin] because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
01-Apr-2024 20:55:08.878 警告 [localhost-startStop-1] org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [/WEB-INF/classes/static/bower_components/sass-bootstrap/examples/screenshots/sticky-footer.jpg] to the cache for web application [/flowable-admin] because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
01-Apr-2024 20:55:08.879 警告 [localhost-startStop-1] org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [/WEB-INF/classes/static/bower_components/sass-bootstrap/examples/screenshots/theme.jpg] to the cache for web application [/flowable-admin] because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
问题原因:
查询Tomcat官方资料https://tomcat.apache.org/tomcat-8.5-doc/config/resources.html之后发现
其中:
cacheMaxSize
The maximum size of the static resource cache in kilobytes. If not specified, the default value is 10240 (10 MiB). This value may be changed while the web application is running (e.g. via JMX). If the cache is using more memory than the new limit the cache will attempt to reduce in size over time to meet the new limit. If necessary, cacheObjectMaxSize will be reduced to ensure that it is no larger than cacheMaxSize/20.
翻译后的解释为:
缓存最大大小
静态资源缓存的最大大小(千字节)。如果未指定,默认值为10240(10兆字节)。该值可以在网络应用程序运行时更改(例如通过JMX)。如果缓存使用的内存超过新的限制,缓存将尝试逐渐减小大小以满足新的限制。如有必要,将减少cacheObjectMaxSize以确保其不大于cacheMaxSize/20。
可以得知是由于flowable本身中存在众多的配置、代码以及静态文件等等,然而静态资源的设置太小,不够使用,导致启动时console警告缓存不够。
解决方法:
在tomcat的conf文件夹下的context.xml配置文件中添加如下配置(配置为增加到102400千字节(100兆字节))
<Resources cachingAllowed="true" cacheMaxSize="102400" />
修改后保存重启,发现问题已经消失