当 运行 在本地从 IntelliJ IDE 时防止 Tomcat 序列化会话

Prevent Tomcat from serializing session when running locally from IntelliJ IDE

我通过捆绑的 Tomcat 和 TomEE Integration 插件成功 运行 Tomcat 8.5.16 locally from IntelliJ 2017.2 终极版。

当停止 Tomcat 服务器时,我收到有关会话中某些对象不可序列化的错误。我不关心序列化会话,因为我希望在服务器弹跳或此类事件的情况下启动新的用户会话。

➠ 如何在从 IntelliJ 调用时停止 Tomcat 序列化会话?

Tomcat 特征

这是一个纯粹的 tomcat 功能,与您如何启动它无关。来自 docs:

Disable Session Persistence

As documented above, every web application by default has standard manager implementation configured, and it performs session persistence across restarts. To disable this persistence feature, create a Context configuration file for your web application and add the following element there:

<Manager pathname="" />

禁用会话持久性的示例

例如在META-INF folder of your web app, add a context.xml文件中如下图。

<!-- 'context.xml' file in 'META-INF' folder of your web app -->
<Context>
    <Manager pathname="" />
</Context>

添加文件夹和文件后,您应该可以将其添加到 IDE. You may need to explicitly add the META-INF folder if one is not already configured within your project. Here is a screen shot in IntelliJ 2017 的项目中。