在Yaml中将debug设置为true而不是@EnableWebSecurity(debug = true)

Mic*_*son 3 spring spring-security

我没有使用Spring Boot,但是我希望能够使用YAML打开/关闭调试,例如:

debug: true
Run Code Online (Sandbox Code Playgroud)

代替:

@EnableWebSecurity(debug = true)
Run Code Online (Sandbox Code Playgroud)

Pra*_*hah 5

您可以使用WebSecurityConfigurerAdapter和进行操作WebSecurity#debug

@Value("${isDebugEnable}")
private Boolean isDebugEnable;

public void configure(WebSecurity web) throws Exception {
    web
        .debug(isDebugEnable)
        . //...
}
Run Code Online (Sandbox Code Playgroud)