如何使用Jetty 7和jetty-maven-plugin保持会话?
问题描述:
我想配置Jetty在磁盘上保留会话,以便重新启动Jetty不会丢失会话,但通过阅读文档我还没有得到它的工作。如何使用Jetty 7和jetty-maven-plugin保持会话?
我使用Jetty Maven plugin(org.mortbay.jetty:jetty-maven-plugin 7.4.3.v20110701
)运行Jetty。
Enabling Persistence for the Maven Jetty Plugin告诉成立HashSessionManager
在插件的sessionHandler
配置部分,但例如,有似乎是老maven-jetty-plugin
,而不是新jetty-maven-plugin
。
我试过有固定的类名像这样(我也不得不添加一个依赖于码头服务器罐子,否则我得到ClassNotFoundExceptions):
<webAppConfig implementation="org.mortbay.jetty.plugin.JettyWebAppContext">
<defaultsDescriptor>${project.build.outputDirectory}/META-INF/webdefault.xml</defaultsDescriptor>
<contextPath>${jetty.contextRoot}</contextPath>
<sessionHandler implementation="org.eclipse.jetty.server.session.SessionHandler">
<sessionManager implementation="org.eclipse.jetty.server.session.HashSessionManager">
<storeDirectory>${basedir}/target/jetty-sessions</storeDirectory>
</sessionManager>
</sessionHandler>
</webAppConfig>
目录目标/码头的会话被创建时,服务器运行,但没有写在那里,会话不会持续,据我所知。
那么,我错过了什么?
答
该文档列出错误的类名称。使用此片段:
<sessionHandler implementation="org.eclipse.jetty.server.session.SessionHandler">
<sessionManager implementation="org.eclipse.jetty.server.session.HashSessionManager">
<storeDirectory>${basedir}/target/sessions</storeDirectory>
<idleSavePeriod>1</idleSavePeriod>
</sessionManager>
</sessionHandler>
我没有一个Eclipse登录来解决它自己的维基。也许你可以抓住一个并修理它以帮助别人。
更新:我将idleSavePeriod
添加到配置中。我第一次以为你刚刚从Eclipse wiki复制错字。
我更新了eclipse.org wiki页面以匹配新的插件类。 – jarnoan