Spring @由概要文件处理的EnableWebSecurity调试布尔标志

Spring @由概要文件处理的EnableWebSecurity调试布尔标志,spring,spring-boot,spring-security,Spring,Spring Boot,Spring Security,注释@EnableWebSecurity包含一个用于启用或禁用调试模式的属性。此属性是一个布尔字段 @EnableWebSecurity(debug = true) 我想通过我使用的spring配置文件启用或禁用该标志。实际上我不能使用SpEL,因为它是字符串。通过配置文件启用/禁用标志是否有简单的解决方法 @Configuration @Order(1) @EnableWebSecurity(debug = true -> *should be handled by profile*)

注释
@EnableWebSecurity
包含一个用于启用或禁用调试模式的属性。此属性是一个布尔字段

@EnableWebSecurity(debug = true)
我想通过我使用的spring配置文件启用或禁用该标志。实际上我不能使用
SpEL
,因为它是
字符串。通过配置文件启用/禁用标志是否有简单的解决方法

@Configuration
@Order(1)
@EnableWebSecurity(debug = true -> *should be handled by profile*)
public class SecurityConfig extends WebSecurityConfigurerAdapter {

其实很简单
WebSecurity
本身将调试模式作为属性。因此,如果覆盖
WebSecurity
,则可以设置调试模式:

@Configuration
@Order(1)
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Value("${isDebugMode}")
    private boolean isDebugMode;

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.debug(isDebugMode);
    }
}