Spring 网络流 2.4.1 和 Spring 安全 4.0.1

Spring Web Flow 2.4.1 and Spring Security 4.0.1

我们在项目中使用了 Spring Web Flow 2.4.1 和 Spring Security 3.x(最高 3.2.6)。然而,在我们升级到 Spring Security 4.0.1 之后,我们遇到了以下异常。有帮助吗?

java.lang.NoSuchMethodError: org.springframework.security.access.vote.AffirmativeBased: method <init>()V not found
at org.springframework.webflow.security.SecurityFlowExecutionListener.decide(SecurityFlowExecutionListener.java:102)

****** 更新的答案 *******

SWF 2.4.2 现已推出 spring。io/blog/2015/09/01/spring-web-flow-2-4-2-released

将解决此问题。

–尼尔·麦圭根

****** 旧答案 *******

为:import org.springframework.security.access.vote.AffirmativeBased

AffirmativeBased() 已弃用。 使用接受选民名单的构造函数

http://docs.spring.io/autorepo/docs/spring-security/3.2.3.RELEASE/apidocs/org/springframework/security/access/vote/AffirmativeBased.html

http://docs.spring.io/autorepo/docs/spring-security/4.0.1.RELEASE/apidocs/org/springframework/security/access/vote/AffirmativeBased.html

AffirmativeBased() 空构造函数已在较新的 Spring Security 4.0.1 中删除(它已在 3.2.6 中标记为已弃用)

org.springframework.webflow.security.SecurityFlowExecutionListener.decide(SecurityFlowExecutionListener.java:102)

SecurityFlowExectionListener#decide 方法在第 102 行调用此空构造函数。

简短回答: Spring Webflow 2.4.1 未针对 Spring 安全 4.0.1 恢复到 3.2.6

长(镜头)答案: 如果你不能恢复并希望继续使用 webflow...这可能是一个长镜头尝试扩展 org.springframework.webflow.security.SecurityFlowExecutionListener 和 @覆盖决定方法。复制粘贴 decide 方法的原始代码,但将第 102 行从

更改为
            abstractAccessDecisionManager = new AffirmativeBased();

            abstractAccessDecisionManager = new AffirmativeBased(voters);

虽然这可能会解决您当前的问题...我怀疑这会揭示更多的不兼容问题,但我认为这个改变是微不足道的,值得一试。