我使用的是Sping Boot 2.7.0,我已经设置了server.reactive.session.timeout=10s
在我的application.properties中。我使用@EnableWebFlux注解,但EnableWebFluxConfiguration类中的代码从未运行过(使用调试器进行了验证,并且我的会话在10秒后不会超时)。在TRACE日志中,我看到
TRACE 279856 --- [ main] o.s.b.a.condition.OnBeanCondition : Condition OnBeanCondition on org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration did not match due to @ConditionalOnMissingBean (types: org.springframework.web.reactive.config.WebFluxConfigurationSupport; SearchStrategy: all) found beans of type 'org.springframework.web.reactive.config.WebFluxConfigurationSupport' org.springframework.web.reactive.config.DelegatingWebFluxConfiguration
这是未创建的bean
@Bean
@ConditionalOnMissingBean(name = WebHttpHandlerBuilder.WEB_SESSION_MANAGER_BEAN_NAME)
public WebSessionManager webSessionManager(ObjectProvider<WebSessionIdResolver> webSessionIdResolver) {
DefaultWebSessionManager webSessionManager = new DefaultWebSessionManager();
Duration timeout = this.serverProperties.getReactive().getSession().getTimeout();
webSessionManager.setSessionStore(new MaxIdleTimeInMemoryWebSessionStore(timeout));
webSessionIdResolver.ifAvailable(webSessionManager::setSessionIdResolver);
return webSessionManager;
}
2条答案
按热度按时间unhi4e5o1#
我把MaxIdleTimeInMemoryWebSessionStore的定义复制到我自己的config类中,并硬编码会话超时,而不是从属性文件中阅读。
dzhpxtsq2#
在application.yml中你可以调整它,这里我把它设置为36000秒。