在不重新启动Tomcat的情况下识别属性文件更改 [英] Recognizing properties file changes without restarting Tomcat

查看:192
本文介绍了在不重新启动Tomcat的情况下识别属性文件更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器有没有办法识别更改,而不会在属性文件更新后重新启动?因为它会在第二次重新启动后导致Java.lang.OutOfMemoryError:PermGen空间。

Is there any way for the server to recognize the changes without restarting after a properties file updated? Because it causes Java.lang.OutOfMemoryError: PermGen space after the second restart.

属性文件位于Web-Inf文件夹下。

The properties file is under Web-Inf folder.

干杯...

推荐答案

没有直接的方法!

Tomcat Webapp类加载器缓存由其加载的每个资源。更改将不可见,除非您重新启动上下文。没有API清除缓存。所有你可以做的是通过反射访问该地图,并调用clear方法。所有资源将根据请求从磁盘重新读取。
清除 HashMap和你的完成!文件监视器不会真正帮助,因为你有一个自定义类加载器。

The Tomcat Webapp Classloader caches every resource which has been loaded by it. A change won't be visible unless you restart the context. There is no API clearing that cache. All you can do is access that map via reflection and call the clear method. All resources will be re-read from disk on request. Clear this HashMap and your are done! The file monitor won't really help since you have a custom classloader.

这篇关于在不重新启动Tomcat的情况下识别属性文件更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆