解决方案:
增加配置类,该类继承【WebSecurityConfigurerAdapter】;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {}
启动类包扫描范围覆盖配置所在包;
@SpringBootApplication(scanBasePackages = {"x.x.x"})
public class SpApplication {
public static void main(String[] args) {
SpringApplication.run(SpApplication.class, args);
}
}
背景:SpringBoot项目,鉴权使用SpringSecurity,浏览器访问服务接口时出现login页面,该页面是security自带的登录页面,没有重写配置则默认使用该策略。