Spring Boot 的 Spring Security 默认凭据是什么?

Spring Boot我正在使用,spring-data-rest-hal-browser一切似乎都很好,除了当我尝试点击 URL 时:http://localhost:8080我被重定向到http://localhost:8080/login使用 HAL 浏览器来导航我的端点,然后我看到一个屏幕,要求输入用户和密码我没有。


登录 Spring Security 的默认凭据是什么?如何更改它们或禁用登录选项?


这是我正在使用的依赖项:


<dependency>

 <groupId>org.springframework.data</groupId>

 <artifactId>spring-data-rest-hal-browser</artifactId>

</dependency>


<dependency>

  <groupId>org.springframework.boot</groupId>

  <artifactId>spring-boot-starter-security</artifactId>

</dependency>

这是登录屏幕:

https://img1.mukewang.com/650aab4500017bb510930335.jpg

UYOU
浏览 102回答 2
2回答

慕哥6287543

运行应用程序后查看控制台输出。如果没有运行时异常,那么您应该可以轻松找到凭据。默认情况下,用户名user和密码始终不同,因此由系统生成。为了更清楚起见,登录页面带有以下依赖项:<dependency>&nbsp; &nbsp; <groupId>org.springframework.boot</groupId>&nbsp; &nbsp; <artifactId>spring-boot-starter-security</artifactId></dependency>另外,如果您想为凭据设置一些值,请转到该application.properties文件并添加这两行:spring.security.user.name=<your/username>spring.security.user.password=<your/password>

拉风的咖菲猫

默认用户名是user当您运行应用程序时,可以在控制台中找到密码。例子:Using&nbsp;generated&nbsp;security&nbsp;password:&nbsp;18ea5687-bc63-4663-9377-e2817c9d2568如果您想自己设置它们,可以通过覆盖以下中的默认值来实现application.properties:spring.security.user.name=stack spring.security.user.password=overflow
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java