本文介绍了@EnableWebSecurity在春天有什么用处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

根据

或者这个 @EnableWebSecurity 描述,用于在我们的项目中启用SpringSecurity。

Or As this @EnableWebSecurity depicts, is used to enable SpringSecurity in our project.

但我的问题是,即使我没有使用 @EnableWebSecurity 注释我的任何类,仍然是应用程序提示输入用户名和密码。(默认行为)

But my question is that even if I don't annotate any of my class with @EnableWebSecurity still the application prompting for username and password.(default behaviour)

所以我收到与 @EnableWebSecurity 相同的行为 @EnableWebSecurity

So I am receiving the same behaviour with @EnableWebSecurity and without @EnableWebSecurity.

有人可以解释这个注释究竟是什么?

Can someone please explain what exactly is this annotation for?

推荐答案

@EnableWebSecurity 是标记注释。它允许Spring找到(它是 @Configuration ,因此, @Component )并自动将类应用于全局 WebSecurity

The @EnableWebSecurity is a marker annotation. It allows Spring to find (it's a @Configuration and, therefore, @Component) and automatically apply the class to the global WebSecurity.

是的,它是默认行为。如果查看类路径,可以找到标有该注释的其他类(取决于您的依赖项):

Yes, it is the default behavior. If you looked at your classpath, you could find other classes marked with that annotation (depends on your dependencies):


  • SpringBootWebSecurityConfiguration ;

  • FallbackWebSecurityAutoConfiguration ;

  • WebMvcSecurityConfiguration

  • SpringBootWebSecurityConfiguration;
  • FallbackWebSecurityAutoConfiguration;
  • WebMvcSecurityConfiguration.

仔细考虑它们,关闭所需的配置或覆盖其行为。

Consider them carefully, turn the needed configuration off, or override its behavior.

这篇关于@EnableWebSecurity在春天有什么用处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 22:15