我经历了这个特殊的问题。我通过将 RememberMeAuthenticationProvider 添加到我的身份验证管理器来解决它。
<beans:bean id="rememberMeAuthenticationProvider"
class="org.springframework.security.authentication.RememberMeAuthenticationProvider">
...
</beans:bean>
<authentication-manager alias="authMgr">
...
<authentication-provider ref="rememberMeAuthenticationProvider">
</authentication-provider>
</authentication-manager>
所以我的身份验证管理器最终得到了两个身份验证提供程序:
<authentication-manager alias="authMgr">
<authentication-provider user-service-ref="customUserDetailsService">
<password-encoder hash="sha">
<salt-source user-property="username" />
</password-encoder>
</authentication-provider>
<authentication-provider ref="rememberMeAuthenticationProvider">
</authentication-provider>
</authentication-manager>
这篇文章说“在你的AuthenticationManager中包含RememberMeAuthenticationProvider”:http ://static.springsource.org/spring-security/site/docs/3.0.x/reference/remember-me.html