我正在使用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
)
那么如何找出用户名和密码呢?
答案 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>