SpringSecurity配置对应的账号密码访问
在 Spring Security 里,默认情况下并没有固定的账号密码,只有当你在项目中 引入了 spring-boot-starter-security 依赖,但没有自己配置用户信息 时,Spring Boot 才会帮你自动创建一个默认用户:
- 默认用户名:
user - 默认密码:在应用启动日志里打印出来的一串随机生成的密码,例如:

Using generated security password: 5e97a7c7-5834-4855-a14b-de168ca6c1a8
这个密码只在程序运行期间有效,每次重启都会生成新的。
而且还会提示 仅在开发模式下用,安全配置密码在生产环境必须更新
This generated password is for development use only. Your security configuration must be updated before running your application in production.
如果你想自定义账号,可以在 application.properties 或 application.yml 里配置:
spring.security.user.name=admin spring.security.user.password=123456
这样启动后就能用 admin / 123456 登录。
在访问的时候会有个这样的账号密码认证来拦截访问

这里输入的就是上面的账号密码了。
到此这篇关于SpringSecurity配置对应的账号密码访问的文章就介绍到这了,更多相关SpringSecurity配置账号密码访问内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
springboot整合prometheus实现资源监控的详细步骤
Spring Boot与Prometheus的整合可以实现对Spring Boot应用的实时监控,有助于更好地维护应用的性能,本文给大家介绍springboot整合prometheus实现资源监控的详细步骤,感兴趣的朋友跟随小编一起看看吧2024-11-11


最新评论