无法建立 AuthenticationEntryPoint。请确保您具有通过命名空间配置的登录机制

No AuthenticationEntryPoint could be established. Please make sure you have a login mechanism configured through the namespace

我正在使用 Spring-security 4.0.4。 我正在尝试为响应 headers 设置安全配置,如下所示- <sec:http use-expressions="true"> <sec:headers defaults-disabled="true"/> </sec:http>

此设置用于禁用安全性中的安全组件header。 但是,如果完成此设置,则在服务器启动期间会抛出以下异常。 Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: No AuthenticationEntryPoint could be established. Please make sure you have a login mechanism configured through the namespace (such as form-login) or specify a custom AuthenticationEntryPoint with the 'entry-point-ref' attribute

根据错误,设置要求 form-login 与上述 setting.Could 一起使用 setting.Could 有人请告诉我为什么会这样吗?

authentication entry point(即身份验证过程由未经身份验证的用户尝试访问受保护资源触发)

你可以为你自己的实现AuthenticationEntryPoint的入口点配置entry-point-ref,就像下面的配置

<http entry-point-ref="youOwnEntrypoint">

或者您可以将 auto-config 设置为 true,它将自动注册登录表单、BASIC 身份验证、注销服务。

<http auto-config="true" >