@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("blah")
.password("blah")
.roles("USER");
}
Spring引导无法扫描您的安全包,因为您需要将安全包或类放在主包下,项目的主类位于基本包中。
如果它不起作用。请分享项目结构和安全类代码,因为这将更有助于解决您的问题。
如果你只需要一个管理员用户,你能尝试设置一个属性文件吗?
spring.security.user.name=您的姓名
spring.security.user.password=您的密码