Servlet.service() for servlet [springmvc] in context with path []
threw exception [Request processing failed; nested exception is
org.springframework.beans.factory.BeanNotOfRequiredTypeExcepti
on: Bean named 'requestDataValueProcessor' must be of type [org.springframework.web.servlet.support.RequestDataValueProcessor],
but was actually of type [org.springframework.security.web.servlet.suppo
rt.csrf.CsrfRequestDataValueProcessor]]
with root cause
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named
'requestDataValueProcessor' must be of type
[org.springframework.web.servlet.support.RequestDataValueProcessor], but was actually of type
[org.springframework.security.web.servlet.support.csrf.CsrfRequestDataValueProcessor]
我收到此错误。
2条答案
按热度按时间sc4hvdpw1#
此问题是在从Spring Security 3.x升级到4.x时导致的。在Spring Security 4中,CSRF现在默认启用。
将以下内容添加到登录页面
Spring Security 3到4迁移指南http://docs.spring.io/spring-security/site/migrate/current/3-to-4/html5/migrate-3-to-4-xml.html#m3to4-xmlnamespace-csrf
wwodge7n2#
我可以通过将CsrfRequestDataValueProcessor的内容克隆到我自己的类中来解决这个问题。这听起来像是类加载器的问题,但这是一个快速修复。
然后将其添加到安全配置中。