【问题标题】:How to detect tomcat context reload如何检测tomcat上下文重新加载
【发布时间】:2012-07-05 17:24:12
【问题描述】:

我有一个 config.properties 文件来将我的应用程序的凭据和 IP 地址存储为键值对。但是,写入此属性文件会在 tomcat 中重新加载应用程序上下文。 我正在写入如下属性文件

   URL propUrl=this.getClass().getClassLoader().getResource(PROPERTIES_FILE);
   prop.store(new FileOutputStream(propUrl.getPath()), null);

所以,

1.) 有没有办法在 Java 中检测 tomcat 上下文重新加载。

2.) 有没有办法防止上下文重新加载和读取 config.properties 文件

【问题讨论】:

标签: java tomcat web-applications


【解决方案1】:
  1. 如果 ServletContextListener 没有帮助。您可以尝试使用 LifeCycleListener
  2. 设置属性reloadable=false 以防止重新加载上下文。

【讨论】:

    【解决方案2】:

    要禁用上下文的自动重新加载(这是 web 应用程序的 Tomcat 术语),请将服务器配置中 <Context> 元素的 reloadable 属性设置为 falseSee here供参考,搜索“reloadable”。

    【讨论】:

      猜你喜欢
      • 2021-09-12
      • 2017-07-08
      • 2023-04-10
      • 1970-01-01
      • 2018-02-13
      • 1970-01-01
      • 2014-05-10
      • 2011-04-04
      • 1970-01-01
      相关资源
      最近更新 更多