12 java spring tomcat spring-mvc spring-boot
我正在使用嵌入式Tomcat在Eclipse中启动Application类来开发Spring Boot和Spring Security的应用程序.每次我重新启动服务器时,我的会话都会消失,我必须再次登录,这非常烦人.
是否可以在服务器重启之间保持会话?
我在Stackoverflow上看到了另一个问题,其中有人问相反,这让我觉得这应该是开箱即用的:
如何通过Manager路径名禁用Spring Boot中的Tomact会话持久性?
我正在使用Gradle运行Spring Boot 1.2.1.
顺便说一句,我知道Spring Loaded,但有时服务器重启是不可避免的.
Far*_*ook 10
根据Spring,这将在1.3.0.M2中修复,最终在1.3.0.RELEASE中修复
然后你要做的就是将以下行添加到你的application.properties文件中.
server.session.persistent=true
Run Code Online (Sandbox Code Playgroud)
在最近的Spring版本中,这已被弃用并替换为:
server.servlet.session.persistent=true
Run Code Online (Sandbox Code Playgroud)
参考https://github.com/spring-projects/spring-boot/issues/2490
更新Tomcat,Jetty和Undertow以在应用程序停止时序列化会话数据,并在应用程序重新启动时再次加载它.
持续会议是选择加入; 通过设置
persistentSessionConfigurableEmbeddedServletContainer或使用属性server.session.persistent=true.修复了gh-2490
小智 6
我只是自己弄清楚了。每次启动应用程序时,Spring都会在/tmpTomcat的基本目录(例如/tmp/tomcat.5990562997404648887.8080)中生成一个新的随机临时目录。由于它在每次启动时都使用不同的文件夹,因此Tomcat无法还原会话。
可以通过使用设置您自己的基本目录来解决此问题server.tomcat.basedir=/tmp。但是,我不认为这是一个修复程序,因为它需要设置特定于操作系统的目录,因此我打开了一个与此有关的错误:https : //github.com/spring-projects/spring-boot/issues/2490
| 归档时间: |
|
| 查看次数: |
10587 次 |
| 最近记录: |