Springboot-启动应用程序后的登录表单

时间:2019-03-18 15:30:39

标签: spring rest spring-boot

我正在使用IntelliJ,并且尝试运行以下示例:

https://www.tutorialspoint.com/spring_boot/spring_boot_bootstrapping.htm

应用程序启动后,当我转到localhost:8080时,它将重定向到 localhost:8080/login并以"Login with Username and Password"

形式

TOMCAT_HOME中没有Tomcat目录(在所有解决此问题的手册中,我应该在提到的目录中拥有文件tomcat-users.xml

那么如何找出用户名和密码呢?

2 个答案:

答案 0 :(得分:0)

我认为这是因为您的类路径上有spring-boot-starter-security,这就是为什么自动配置Spring安全性的原因。验证您的pom.xml

中是否具有以下依赖项
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>

您还可以注意到,在应用程序启动时,在应用程序控制台中您会看到以下日志

Using default security password: ce6c3d39-8f20-4a41-8e01-803166bb99b6

这意味着Spring Security已自动将其添加为您的密码,用户ID为user

如果要将此密码更改为其他密码,可以在 application.properties 中将其配置为

security.user.password=password

有关更多详细信息,请遵循此Spring Security References

答案 1 :(得分:0)

我遇到了这个问题,我启动了一个应用程序,搜索了localhost:// 8080。 我通过删除POM.XML文件中的此依赖项来诊断错误

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>