Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Spring security中出现震荡会话时使第一个登录会话无效_Java_Spring_Spring Boot_Spring Security - Fatal编程技术网

Java 在Spring security中出现震荡会话时使第一个登录会话无效

Java 在Spring security中出现震荡会话时使第一个登录会话无效,java,spring,spring-boot,spring-security,Java,Spring,Spring Boot,Spring Security,它是集群环境 在我的currnet spring引导应用程序中,我希望在给定时间允许5个并发会话。当用户尝试第六次登录时,第六次会话应为有效会话,并应使第一次会话无效(即从第一次会话注销),因此活动会话的总数将为5 是否可以通过以下代码中的配置来实现 @Override protected void configure(HttpSecurity http) throws Exception { http.sessionManagement().maximumSessions(5) } 好像是的

它是集群环境

在我的currnet spring引导应用程序中,我希望在给定时间允许5个并发会话。当用户尝试第六次登录时,第六次会话应为有效会话,并应使第一次会话无效(即从第一次会话注销),因此活动会话的总数将为5

是否可以通过以下代码中的配置来实现

@Override
protected void configure(HttpSecurity http) throws Exception {
http.sessionManagement().maximumSessions(5)
}

好像是的。如本文所述。你已经试过了吗

要启用允许同一用户进行多个并发会话的场景,应在XML配置中使用
元素:

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.sessionManagement().maximumSessions(2)
}

代码也来自此站点。

应用程序是否使用负载平衡器在多台计算机上进行平衡?是的,它是群集环境这是必不可少的!请在你的问题中指出这一点!谢谢你的澄清。让我测试一下。注意,它是群集的。服务器级别的同步无法跨多个实例工作。我得到了这个链接(),它在集群环境中应该可以正常工作。有人能证实吗?@PeterRader,这个信息是在我发布我的答案后添加的-但谢谢你的否决票。@Rainer你的解决方案很好,别误会我。否决票并不反对你,你的回答风格很好,而且与官方消息来源有关。不幸的是,问题的背景已经发生了变化,它是1。在已更改的上下文中不再有用。2.引导其他人以这种方式投入时间解决问题,甚至可能通过所有测试。如果可以的话,我会投反对票,但会投你一票。
@Override
protected void configure(HttpSecurity http) throws Exception {
    http.sessionManagement().maximumSessions(2)
}