我试图更改身份验证的用户名和密码,但我仍然得到了一个随机生成的密码,我必须输入该密码才能登录


@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=您的密码

相关内容

最新更新