SpringBoot开发中关闭Security安全策略报错:Deprecated: The security auto-configuration is no longer customizable
程序员文章站
2022-05-30 09:47:59
...
如果在yml文件中配置
security:
basic:
enabled: false
idea会报错:Deprecated: The security auto-configuration is no longer customizable less... (Ctrl+F1)
Checks Spring Boot application .yaml configuration files. Highlights unresolved and deprecated configuration keys and invalid values. Works only for Spring Boot 1.2 or higher.
这是因为在SpringBoot2.0版本后安全配置将不再是可定制的,解决办法:
1、在启动类上,移除默认自动启动的安全策略
@SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})
2、可以将SpringBoot的版本更换为2.0之前的,更新项目依赖,就可以直接在yml文件中配置
security:
basic:
enabled: true
3.写一个配置类继承WebSecurityConfigurerAdapter 接口,覆盖configure方法,调用http.httpBasic().disable();方法
建议使用这种
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().disable();
}
}
上一篇: 4:三大范式
下一篇: java----JDOM解析XML