停用Spring Boot应用程序的TOMCAT安全性



你好,我使用的是Spring Boot 2.4.3

我的应用程序是一个Maven多模块应用程序,由Angular/Spring Boot/Spring Security techno组成。我使用了以下教程:https://spring.io/guides/tutorials/spring-security-and-angular-js/#_the_login_page_angular_js_and_spring_security_part_ii通过执行>在我的父模块上的mvn clean包中,我创建了一个jar,并用java-jar-backend0.1-SNAPSHOT.jar运行。嵌入的角前端功能很好,我测试了它。

通常,当我启动Spring Boot时,它应该给我一个对应于";用户";标识符,如下图所示

在此处输入图像描述

但当我启动我的Spring Boot时,没有显示密码。因此,我最终得到了一个身份验证窗口,该窗口要求我输入用户和密码

在此处输入图像描述

我认为这就是Spring Boot中TOMCAT服务器的安全性。理想的情况是禁用这个安全性,我不知道怎么做。我做了很多工作都没有找到

我试图在application.properties中添加以下行,但没有成功

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
security.user.name=user
security.user.password=password
spring.security.user.name=user
spring.security.user.password=password
security.basic.enabled=false
management.security.enabled =false

我找到了解决方案

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity security) throws Exception
{
security.httpBasic().disable();
}
}

但我只能看到显示的index.html页面。应用程序不考虑角度路线

最新更新